Is there a good JavaScript minifier?
JavascriptMinifyJavascript Problem Overview
What JavaScript minifier do you recommend?
Javascript Solutions
Solution 1 - Javascript
UglifyJS2, used by the jQuery project.
Solution 2 - Javascript
Active
Deprecated
Google Closure Compiler generally achieves smaller files than YUI Compressor, particularly if you use the advanced mode, which looks worryingly meddlesome to me but has worked well on the one project I've used it on:
Several big projects use UglifyJS, and I've been very impressed with it since switching.
Solution 3 - Javascript
JavaScript Minifier gives a good API you can use programatically:
curl -X POST -s --data-urlencode 'input=$(function() { alert("Hello, World!"); });' http://javascript-minifier.com/raw
Or by uploading a file and redirecting to a new file:
curl -X POST -s --data-urlencode 'input@ready.js' http://javascript-minifier.com/raw > ready.min.js
Hope that helps.
Solution 4 - Javascript
If you are using PHP you might also want to take a look at minify which can minify and combine JavaScript files. The integration is pretty easy and can be done by defined groups of files or an easy query string. Minified files are also cached to reduce the server load and you can add expire headers through minify.
Solution 5 - Javascript
There are several you can use/try:
- YUI compressor
- jsmin
- Microsoft Ajax minifier (has hypercrunching)
Solution 6 - Javascript
Pretty Diff - http://prettydiff.com/?m=minify
Solution 7 - Javascript
Sometimes i use this: http://closure-compiler.appspot.com/home
Solution 8 - Javascript
This tool: https://jscompressor.com">jscompressor.com</a> is pretty good.