So your original "html" (javascript in a script tag?) was a single function call.
Obviously the extra stuff didn't appear magically.
So, for instance, you aren't editing this html in a text editor. What are you using to edit it? Presumably that is adding the extra code.
Wrapping JS code in an "anonymous function" is one way to restrict the scope of any variables defined in the JS, to keep them from being global. (But what if you wanted global variable?)
Anyway, how are you editing this html?
Is the extra stuff causing your JS to not function properly?
Or is it just the sight of the extra stuff that's annoying?