5 ms·
JS minimizers tend to remove all the newlines, so semicolons are often necessary if you use one.
by Terhorst 16y ago
JS minimizers tend to remove all the newlines, so semicolons are often necessary if you use one.
- bruceboughton 16y agoWas 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.
- wlievens 16y agoI would hope that minifiers use a JS parser!
- bruceboughton 16y agoI imagine much of the minification could be done using just a lexer rather than a full parser. I'm quite probably wrong though.
- x5315 16y agoThis 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.