Hacker News new | ask | show | jobs
by Terhorst 5806 days ago
JS minimizers tend to remove all the newlines, so semicolons are often necessary if you use one.
2 comments

This just isn't true.

The YUI minifier, for example, works perfectly fine without semicolons in the original. Equally, the Google Closure Compiler does also.

If you're using a minifier that just removes new lines and suffers without semicolons, I think you should rethink your minifcation process.

Was going to say that this is clearly a bug in the minifier but then I thought about the effort involved in properly supporting non-terminated lines (or even detecting it). You're going to end up writing a JS parser.

This really shows the cost of this syntactic nicety to the language.

I would hope that minifiers use a JS parser!
I imagine much of the minification could be done using just a lexer rather than a full parser. I'm quite probably wrong though.