Yes, it's quite safe, and perfectly valid JS that every browser understands. Closure compiler, yuicompressor, packer, and jsmin all can properly minify it.
I can assure you that packer requires semi-colons. It won't in the next release but you definitely need them if you are using the current online version.
Why? At least several exist and you can just use one of them. And if you need a minifier use yuicompressor or Closure compiler. They parse real JS not just some subset of it.
Implicit variable assignments, weird scoping for eval, with and a lot more was also part of JavaScript and is gone in the strict mode. What's your point?
I am talking about parsing. Because it's very damn common to parse programming languages:
string extraction for internationalization
static analysis
implementing an actual interpreter (necessary sometimes)
detecting end of statements for feeding an interactive interpreter
parsing javascript for automatic comment and function signature extraction (documentation tools)
And a lot more. JavaScript is suppose to be a language that is somewhat easy to implement, easy to sandbox and works the same in different interpreters. Semicolon insertion, the weird rules for the regular expression literal, weird rules for function statements versus function expressions and more are standard features that often work different in different implementations of ECMAScript. You will run on different implementations, for that the language is just too damn common.
So save yourself the trouble and write with semicolons. A lot of tools will not do the extra trouble and implement semicolon insertion. And if they do, chances are they do it wrong and might choke on your code.
10
u/9jack9 Feb 05 '11
I can assure you that packer requires semi-colons. It won't in the next release but you definitely need them if you are using the current online version.