<p>What is the the best JavaScript compressor available? I'm looking for a tool that:</p>

<ul>
<li>is easy to use</li>
<li>has a high compression rate</li>
<li>Produce reliable end results (doesn't mess up the code)</li>
</ul>

[{'answer_id': 28938, 'author': 'kamens', 'author_id': 1335, 'author_profile': 'https://Stackoverflow.com/users/1335', 'pm_score': 5, 'selected': False, 'text': '<p><a href="http://developer.yahoo.com/yui/compressor/" rel="noreferrer">YUI Compressor</a> is the way to go. It has a great compression rate, is well tested and is in use among many top sites, and, well, personally recommended by me.</p>\n\n<p>I\'ve used it for my projects without a single JavaScript error or hiccup.  And it has nice documentation.</p>\n\n<p><strike>I\'ve never used its CSS compression capabilities, but they exist as well.</strike> CSS compression works just as well.</p>\n\n<p><em>Note: Although Dean Edwards\'s /<a href="http://dean.edwards.name/packer/" rel="noreferrer">packer</a>/ achieves a better compression rate than YUI Compressor, I ran into a few JavaScript errors when using it.</em></p>\n'}, {'answer_id': 28939, 'author': 'Mark Biek', 'author_id': 305, 'author_profile': 'https://Stackoverflow.com/users/305', 'pm_score': 2, 'selected': False, 'text': '<p><a href="http://crockford.com/javascript/jsmin" rel="nofollow noreferrer">JSMin</a> is another one.</p>\n'}, {'answer_id': 28942, 'author': 'chakrit', 'author_id': 3055, 'author_profile': 'https://Stackoverflow.com/users/3055', 'pm_score': 3, 'selected': False, 'text': '<p>Try <a href="http://www.crockford.com/javascript/jsmin.html" rel="nofollow noreferrer">JSMin</a>, got C#, Java, C and other ports and readily available too.</p>\n'}, {'answer_id': 28953, 'author': 'juan', 'author_id': 1782, 'author_profile': 'https://Stackoverflow.com/users/1782', 'pm_score': 1, 'selected': False, 'text': '<p><a href="http://blog.madskristensen.dk/post/Optimize-WebResourceaxd-and-ScriptResourceaxd.aspx" rel="nofollow noreferrer">Here\'s the source code</a> of an HttpHandler which does that, maybe it\'ll help you</p>\n'}, {'answer_id': 28954, 'author': 'Pat', 'author_id': 238, 'author_profile': 'https://Stackoverflow.com/users/238', 'pm_score': 7, 'selected': False, 'text': '<p>Revisiting this question a few years later, <a href="http://github.com/mishoo/UglifyJS" rel="nofollow noreferrer">UglifyJS</a>, seems to be the best option as of now.</p>\n\n<p>As stated below, it runs on the NodeJS platform, but can be easily modified to run on any JavaScript engine.</p>\n\n<p>--- Old answer below---</p>\n\n<p>Google released <a href="https://github.com/google/closure-compiler" rel="nofollow noreferrer"><strong>Closure Compiler</strong></a> which seems to be generating the smallest files so far as seen <a href="http://blog.feedly.com/2009/11/06/google-closure-vs-yui-min/" rel="nofollow noreferrer">here</a> and <a href="http://news.ycombinator.com/item?id=924426" rel="nofollow noreferrer">here</a></p>\n\n<p>Previous to that the various options <a href="http://www.julienlecomte.net/blog/2007/08/13/" rel="nofollow noreferrer"> were as follow </a></p>\n\n<p>Basically <a href="http://dean.edwards.name/packer/" rel="nofollow noreferrer">Packer</a> does a better job at initial compression , but if you are going to gzip the files before sending on the wire (which you should be doing) <a href="http://www.julienlecomte.net/yuicompressor/" rel="nofollow noreferrer">YUI Compressor</a> gets the smallest final size.</p>\n\n<p>The tests were done on jQuery code btw.</p>\n\n<ul>\n<li>Original jQuery library 62,885 bytes , 19,758 bytes after gzip</li>\n<li>jQuery minified with JSMin 36,391 bytes , 11,541 bytes after gzip</li>\n<li>jQuery minified with Packer 21,557 bytes , 11,119 bytes after gzip</li>\n<li>jQuery minified with the YUI Compressor 31,822 bytes  , 10,818 bytes after gzip</li>\n</ul>\n\n<p>@<a href="https://stackoverflow.com/users/2434/daniel-james">daniel james</a> mentions in the comment <a href="http://compressorrater.thruhere.net/" rel="nofollow noreferrer">compressorrater</a> which shows Packer  leading the chart in best compression, so I guess ymmv </p>\n'}, {'answer_id': 28988, 'author': 'Jason Bunting', 'author_id': 1790, 'author_profile': 'https://Stackoverflow.com/users/1790', 'pm_score': 3, 'selected': False, 'text': '<p>I use <a href="http://shrinksafe.dojotoolkit.org/" rel="nofollow noreferrer"><strong>ShrinkSafe</strong> from the Dojo project</a> - it is exceptional because it actually uses a JavaScript interpreter (<a href="http://www.mozilla.org/rhino/" rel="nofollow noreferrer">Rhino</a>) to deal with finding symbols in the code and understanding their scope, etc. which helps to ensure that the code will work when it comes out the other end, as opposed to a lot of compression tools which use regex to do the same (which is not as reliable).</p>\n\n<p>I actually have an MSBuild task in a <a href="http://www.microsoft.com/downloads/details.aspx?familyid=0AA30AE8-C73B-4BDD-BB1B-FE697256C459&amp;displaylang=en" rel="nofollow noreferrer">Web Deployment Project</a> in my current Visual Studio solution that runs a script which in turn runs all of the solution\'s JS files through ShrinkSafe before we deploy and it works quite well.</p>\n\n<p><strong>EDIT:</strong> By the way, "best" is open to debate, since the criteria for "best" will vary depending on the needs of the project. Personally, I think ShrinkSafe is a good balance; for some people that think smallest size == best, it will be insufficient.</p>\n\n<p><strong>EDIT:</strong> It is worth noting that the YUI compressor also uses Rhino.</p>\n'}, {'answer_id': 29115, 'author': 'jimg', 'author_id': 2621, 'author_profile': 'https://Stackoverflow.com/users/2621', 'pm_score': 1, 'selected': False, 'text': '<p><a href="http://brilaps.com/index.php?content=byuic" rel="nofollow noreferrer" title="Here">Here</a> is a YUI compressor script (<a href="http://brilaps.com/index.php?content=byuic" rel="nofollow noreferrer" title="Byuic">Byuic</a>) that finds all the js and css down a path and compresses /(optionally) obfuscates them.  Nice to integrate into a build process.</p>\n'}, {'answer_id': 32453, 'author': 'jcoglan', 'author_id': 3424, 'author_profile': 'https://Stackoverflow.com/users/3424', 'pm_score': 2, 'selected': False, 'text': "<p>If you use Packer, just go far the 'shrink variables' option and gzip the resulting code. The base62 option is only for if your server cannot send gzipped files. Packer with 'shrink vars' achieves better compression the YUI, but can introduce bugs if you've skipped a semicolon somewhere.</p>\n\n<p>base62 is basically a poor man's gzip, which is why gzipping base62-ed code gives you bigger files than gzipping shrink-var-ed code.</p>\n"}, {'answer_id': 65633, 'author': 'Paweł Hajdan', 'author_id': 9403, 'author_profile': 'https://Stackoverflow.com/users/9403', 'pm_score': 1, 'selected': False, 'text': '<p><a href="http://www.bananascript.com/" rel="nofollow noreferrer">bananascript.com</a> used to give me best results.</p>\n'}, {'answer_id': 962155, 'author': 'MicTech', 'author_id': 69684, 'author_profile': 'https://Stackoverflow.com/users/69684', 'pm_score': 1, 'selected': False, 'text': '<p><strong>KJScompress</strong></p>\n\n<p><a href="http://opensource.seznam.cz/KJScompress/index.html" rel="nofollow noreferrer">http://opensource.seznam.cz/KJScompress/index.html</a></p>\n\n<blockquote>\n  <p>Kjscompress/csskompress is set of two\n  applications (kjscompress a\n  csscompress) to remove non-significant\n  whitespaces and comments from files\n  containing JavaScript and CSS. Both\n  are command-line applications for\n  GNU/Linux operating system.</p>\n</blockquote>\n'}, {'answer_id': 2866426, 'author': 'woto', 'author_id': 237090, 'author_profile': 'https://Stackoverflow.com/users/237090', 'pm_score': 2, 'selected': False, 'text': '<blockquote>\n  <p>In searching silver bullet, found this\n  question. For Ruby on Rails\n  <a href="http://github.com/sstephenson/sprockets" rel="nofollow noreferrer">http://github.com/sstephenson/sprockets</a></p>\n</blockquote>\n'}, {'answer_id': 3541878, 'author': 'mishoo', 'author_id': 154985, 'author_profile': 'https://Stackoverflow.com/users/154985', 'pm_score': 8, 'selected': True, 'text': '<p>I recently released <a href="http://github.com/mishoo/UglifyJS" rel="noreferrer">UglifyJS</a>, a JavaScript compressor which is written in JavaScript (runs on the NodeJS <a href="http://en.wikipedia.org/wiki/Nodejs" rel="noreferrer">Node.js</a> platform, but it can be easily modified to run on any JavaScript engine, since it doesn\'t need any <code>Node.js</code> internals).  It\'s a lot faster than both <a href="http://developer.yahoo.com/yui/compressor/" rel="noreferrer">YUI Compressor</a> and <a href="http://en.wikipedia.org/wiki/Google_Closure_Tools" rel="noreferrer">Google Closure</a>, it compresses better than <a href="http://en.wikipedia.org/wiki/Yahoo!_UI_Library" rel="noreferrer">YUI</a> on all scripts I tested it on, and it\'s safer than Closure (knows to deal with "eval" or "with").</p>\n\n<p>Other than whitespace removal, UglifyJS also does the following:</p>\n\n<ul>\n<li>changes local variable names (usually to single characters)</li>\n<li>joins consecutive var declarations</li>\n<li>avoids inserting any unneeded brackets, parens and semicolons</li>\n<li>optimizes IFs (removes "else" when it detects that it\'s not needed, transforms IFs into the &amp;&amp;, || or ?/: operators when possible, etc.).</li>\n<li>transforms <code>foo["bar"]</code> into <code>foo.bar</code> where possible</li>\n<li>removes quotes from keys in object literals, where possible</li>\n<li>resolves simple expressions when this leads to smaller code (1+3*4 ==> 13)</li>\n</ul>\n\n<p>PS: Oh, it can "beautify" as well. ;-)</p>\n'}, {'answer_id': 3542570, 'author': 'Alex', 'author_id': 413512, 'author_profile': 'https://Stackoverflow.com/users/413512', 'pm_score': 1, 'selected': False, 'text': '<p><a href="http://www.iteral.com/jscrush/" rel="nofollow noreferrer" title="JS Crush">Js Crush</a> is a good compressor to use after you have minified.</p>\n'}]
['https://Stackoverflow.com/questions/28932', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1363/']