The folks over at Google have hit another winner.If you have'nt been introduced to Google's Closure Compiler you missing out on a great tool.To put it in Google's own words:
It has a good API so you can tweak quite a bit of the program output. I would recommend, if you have several scripts or programs to compile, to use a good batch command and just input the JS file names as the variable's each time. I have noticed it needs the files in the order they would normally load. If you don't do this you may run into sets and calls in the output file that can't be reached. Much like loading a JS call in your header before the JS function is loaded. Also, there is a limit to the number of files it can compile together. The command line version has no limit as far as size of file. If you have several JS files there is a python library add on companion to help with loading the files in the correct order.
The program will also do code checking but, as with any testing program, you should only use the warnings or errors as guidelines to troubleshoot. I had some warnings in one program but they all pointed to some code the compiler didn't grasp. It still compiled and ran normally after the compilation. You should still check any warnings and especially errors to see if it isn't something you could tweak or fix.
by Jim Atkins "thedosmann"