1. Put an end to that statement by a ‘;’
/*the first statement will get mixed up with the second one*/
var bad = 'this is not good'
var good = 'this is okay';
2. Always use multi-line comment delimiters (even for single line comments)
Using single line comment delimiters(//) will comment out the next statement upon compaction. So always use multi-line ones (/*…*/) for commenting.
//the next statement will get commented out
var commented = 'does it matter?';
That’s the two of them. And in case if you are looking for tools to compact your JS codes, here’s a couple of them:
1. JSMIN By Douglas Crockford
2. Packer by Dean Edwards