Hacker News new | ask | show | jobs
by madrobby 5184 days ago
Yeah, the semicolons where just there because "that's how you write JavaScript, right?". After reading Mislav's article and of course working with him on Zepto I realized that actually, the semicolons don't do anything; and I like the code better without them. (I'm also doing a lot of Ruby and CoffeeScript, so I'm biased, I suppose.)

So yes, you could say my taste changed, but there's good a good reason behind it—the semicolons are optional, and Zepto is all about concise code.

1 comments

The one argument I've heard from keeping the semi-colons is to make life easier for minification tools. Is this not an issue?
It breaks SOME minifiers. There was some inlining tool used by some mobile ISPs that basically downloaded referenced JS files in <script> tags and injected them inline to get rid of another HTTP request. They broke, because they are stupid, broken tools.

A correct minifier works on the AST of the code anyway (at least in the abstract). It works on the semantic meaning of the code, so it interprets semicolons or the lack thereof exactly the way any other implementation would.

The first case with the broken inlining tool is typically not actually an issue, because your semicolonless code gets put through a minifier which probably adds a bunch of semicolons again :)

It is not an issue. Zepto uses UglifyJS and there have been no issues whatsoever.