This is interesting, it highlights how browsers parse scripts. Best guess is that when you remove the separators, the browser parsing the container script first, and attempting to call SnapABug.addButton, -then- it's handle the document.write. That's a guess though.
–
Mike RobinsonNov 14 '12 at 19:33

1 Answer
1

The first script puts script tag into HTML which loads snapabug.js and loading this resource is synchronous. So executing next scripts, which is SnapABug.addButton(...), is suspended until the resource will be downloaded and interpreted. This way, SnapABug object is visible in the following scripts.

If you put all JavaScript code in one script tag, it is executed as one batch. There is no SnapABug object in global scope because the provided script has not been downloaded yet.