Is there a good JavaScript minifier?

JavascriptMinify

Javascript 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:

Solution 6 - Javascript

Solution 7 - Javascript

Solution 8 - Javascript

Solution 9 - Javascript

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser160820View Question on Stackoverflow
Solution 1 - JavascriptAndreas HofmannView Answer on Stackoverflow
Solution 2 - JavascriptTim DownView Answer on Stackoverflow
Solution 3 - JavascriptchiltsView Answer on Stackoverflow
Solution 4 - Javascript2ndkauboyView Answer on Stackoverflow
Solution 5 - JavascriptKris van der MastView Answer on Stackoverflow
Solution 6 - JavascriptaustincheneyView Answer on Stackoverflow
Solution 7 - JavascriptFilipe CostaView Answer on Stackoverflow
Solution 8 - JavascriptMartinPalermoView Answer on Stackoverflow
Solution 9 - JavascripttomView Answer on Stackoverflow