What happens to comments in a minified JavaScript file? How can the browser know when the end of the comment is when everything is condensed to one line? Take this little example, I have Google tracking code like this:
//Google tracking
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '123456']);
The minified version pulls everything into one line
// Google tracking var _gaq = _gaq || []; _gaq.push(['_setAccount', '123456']);
There are more statements, but when I examine the JavaScript code in an editor, it looks like one giant comment (more or less). Is there a hidden character that tells the browser when to end a comment or is this code just not being executed?
Minifiers strip comments or insert line-breaks. For example, Closure Compiler’s FAQ says:
Sometimes you really need a comment in which case they put in a line break.
Minifiers also tend to break lines occasionally, because some interpreter’s source code parsers crashed or performed really slowly on really long lines.
https://bugzilla.mozilla.org/show_bug.cgi?id=634444