I love to comment code. Sometimes I think it's past the point of usefulness, where my code looks like it might be approaching half comments. That could be bad, but each time I come into code cold, after a break, I'm awfully glad the commenting is there. I hope it's at least half as helpful to others that use my jive.

But there is at least one place that lots of comments probably isn't helpful, for two reasons, and that's in code that's sent via network to your user. If it's a javascript include, comments are less useful. Unlike, well, most anything else, that compiles your code to some not exactly interpreted state, javascript sends EVERYTHING to your user.

I'll admit, I'm often a bad programmer, and leave everything in there, helping only those two want to prank my code or, more likely, myself when I want to remember what I did in a past project and don't have my codebase handy.

But ultimately comments are bad news in Javascript because 1.) you want to obfuscate how your code works in the wild and 2.) more bytes means more network traffic for your server to pump out means, ultimately, slower performance, even in the 2010s.

So the easy way out is to minimize your Javascript. It looks like The Right Way to do that is with Yahoo's YUI Compressor:

In terms of code minification, the most widely used tools to minify JavaScript code are Douglas Crockford's JSMIN, the Dojo compressor and Dean Edwards' Packer. Each of these tools, however, has drawbacks. JSMIN, for example, does not yield optimal savings (due to its simple algorithm, it must leave many line feed characters in the code in order not to introduce any new bugs).
...
The YUI Compressor is JavaScript minifier designed to be 100% safe and yield a higher compression ratio than most other tools. Tests on the YUI Library have shown savings of over 20% compared to JSMin (becoming 10% after HTTP compression).


Goodbye comments! And hello greater than average savings.