UglifyJS 2 is an excellent tool to help you minify your JavaScript! It's a tried and tested tool, used by libraries such as jQuery.
This is a simple wrapper for the browser around the minifier; the hard work is done by Mihai Bazon. If you need an automated solution, I suggest checking out the source code, intended for Node.JS.
Do you want to help improve this tool? It's on Github.
This wrapper for the browser was created by Dan Wolff.