Why do we have newlines in minified JavaScript?
javascript, minify, optimization, performance
Solution
jQuery currently use UglifyJS to minify their source code. In their build script, they specifically set the `max_line_length` directive to be `32 * 1024`:
The documentation for UglifyJS has this to say on the `max-line-len` directive;
`--max-line-len` (default 32K characters) — add a newline after around 32K characters. I’ve seen both FF and Chrome croak when all the code was on a single line of around 670K. Pass –max-line-len 0 to disable this safety feature.
Problem
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.