Re:Poll: Semicolons in JavaScript
by Terhorst on Monday July 26, 2010 @08:26AM
(#1547796)
JS minimizers tend to remove all the newlines, so semicolons are often necessary if you use one.
[ Parent
| on HN ]
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.
Re:Poll: Semicolons in JavaScript
by bruceboughton on Monday July 26, 2010 @08:40AM
(#1547829)
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!
Re:Poll: Semicolons in JavaScript
by bruceboughton on Monday July 26, 2010 @10:20AM
(#1548070)
I imagine much of the minification could be done using just a lexer rather than a full parser. I'm quite probably wrong though.