I know about a similar question but it is a tiny bit off from what I am asking here, so please don't flag
it as a duplicate.
When you see the production version of jQuery, why is there a newline after a while? I downloaded a copy and deleted all the newlines (apart from the licence) and it still worked. (I ran the entire unit test suite against my changes on Mozilla Firefox, Google Chrome and Opera.)
I know three newlines (not counting the license) is not going to slow it down a lot, but still, doesn't every tiny bit help?
I have assigned myself a small challenge, to squeeze every little bit of performance out of my JavaScript code.
jQuery currently use UglifyJS to minify their source code. In their build script, they specifically set the
max_line_length
directive to be32 * 1024
:The documentation for UglifyJS has this to say on the
max-line-len
directive;The lines (excluding the license) are all around 30k characters in length. It could be to avoid bugs where some Javascript parsers die on extremely long lines. This probably won't happen on today's browsers but maybe some older or more obscure ones have such limits.
(Old answer below, which might also be applicable, just not in this case)
This might be because JSMin, a popular Javascript minifier will retain line feeds in the output under certain conditions. This is because in Javascript line feeds are significant if you leave out semicolons, for example. The documentation says:
Other minifiers might have similar rules.
So this is mostly a precaution against accidentally removing a line feed that may be necessary, syntax-wise. The last thing you want is that your minified JS won't work anymore because the minifier destroyed its semantics.
Regarding »I know three newlines (not counting the license) is not going to slow it down a lot, but still, doesn't every tiny bit help?«: When your server uses gzip compression the difference will likely be moot anyway.
To cite the Closure Compiler FAQ:
This is relevant to any minification programs in general.