When putting the finishing touches on a site, it is often advisable to minify the JavaScript code. This process reduces download time for all users of the site, especially when coupled with server-side compression.
Created by Douglas Crockford, JSMin is a filter that removes comments and unnecessary whitespaces from JavaScript files. It typically reduces file size by half, resulting in faster downloads, especially when combined with server-based file compression. Some web sites host the tool to allow users to minify their code by pasting it into a textarea. JSMin can be downloaded as an MS-DOS .exe
file or as source code written in a variety of programming languages: http://www.crockford.com/javascript/jsmin.html.
The YUI Compressor is "designed to be 100% safe and yield a higher compression ratio than most other tools". As of version 2.0, it is also able to minify CSS files. It requires Java version 1.4 or greater: http://developer.yahoo.com/yui/compressor/.
This new service from Google performs a similar compression to JSMin, and in some tests has been found to achieve a higher degree of compression. The compiler is available as both a standalone application and an on-demand API.
This tool also integrates a JavaScript syntax checker that warns of possible errors and code defects: http://code.google.com/closure/compiler/.
This JavaScript compressor/obfuscator by Dean Edwards was used to compress the source code of previous versions of jQuery. The tool is available as a web-based tool or as a free download. The resulting code is very efficient in file size at a cost of a small increase in execution time. Although it is no longer officially recommended, it may be a legitimate option when server-side file compression is not available: