in reply to Removing javascript comments
If you feel like experimenting, take a look at JE::Parser. Probably not for newbies, though...
Otherwise, you can take advantage of a few facts:
javascript string and regex literals are always single line. This means if you go trough the code line by line, ignoring string and regex literals, you can safely assume** any /* .. */ and // ... constructs left are comments (javascript does not allow for an empty regex literal). As I mentioned before, regex literals will be tricky, since the JS grammar for where regexes are valid (instead of divide operators) are fairly tricky, IOW, you will need to distinguish between
andvar res = a / 4 /* whatever */ ^^^^^^^^^^^^^^ comment
for instance.var res = /bla \/* .*/.exec("stuff"); ^^^^^^^ not a comment
** in fact you can't, but it's /probably/ good enough.
update: fixed js code.