Best javascript compiler/minifier

I remember having seen a new javascript compiler/ minifier on github which should even be better than google's closure compiler. Unluckily I can't remember its name and find it again. Maybe someone can help me? :)

Thanks, Corin

Answers


Possibly UglifyJS? It's the minifier that the jQuery project is currently using.

Check out these speed comparisons.


See the statistics src: http://axod.blogspot.ca/2010/01/google-closure-compiler-advanced-mode.html

compare JSMin, by Douglas Crockford and Yahoo! YUI

Minifier           | Bytes   |% of original| gz Bytes | gz % original
None               | 428,264 |    100%     |   91,750 |     100%
JSMin              | 249,372 |     58%     |   57,338 |     62%
YUI                | 235,214 |     55%     |   55,990 |     61%
Closure (STANDARD) | 219,446 |     51%     |   53,515 |     58%
Closure (ADVANCED) | 166,774 |     39%     |   47,372 |     52%

Closure takes the idea of a Javascript minifier a step further. It does this by doing real compilation to remove unused code, inlines variables and rewrites code to make it as small as possible.

Just for reference, you can access the Google Closure Compiler UI here http://closure-compiler.appspot.com/home


AFAIK Closure Compiler's ADVANCED mode is the only game in town if you want global dead code removal (aka tree shaking) and optimization. Which is why projects like emscripten and ClojureScript, and Dart javascript translator use it.


This is an old question, but I came across some new information and wanted to share. I found a specialized minifier on GitHub called RegPack, https://github.com/Siorki/RegPack. I say specialized because it is intended to optimize small (1KB-4KB) files and works with Canvas, WebGL, and Audio components in JavaScript. The results are fairly astounding but also specific to the kind of JavaScript you are writing.

Having noted that, I just ran Closure Compiler in standard mode against a library I wrote, https://github.com/robertdmunn/gadget-ui, to compare the output with UglifyJS, which I am using through Grunt. The base code is 20KB, Uglifier and Closure Compiler (std mode) both made it 10KB. For most use cases, I see that as good enough. Closure advanced mode only reduced it to 9KB. For edge cases - web scale - 10% smaller is decent. Consider, though, that gzip compression will reduce file size by 60-80% in my experience, so the 10% reduction using advanced mode only saves you 2-4% above standard mode if you use gzip. 2-4% is valuable at web scale, but for most developers, it might not be worth the potential problems introduced.


Need Your Help

How to configure Sublime Text 2/3 to use direct Ctrl+Tab order and to create new tabs after the last one?

sublimetext2 sublimetext3 sublimetext

When I press Ctrl+Tab, Ctrl+Shift+Tab or Ctrl+W the tab I get switched to is not the one just near the one I was on (as I would like to) but to some else. When I press Ctl+N the new tab is created ...

Limiting CGAffineTransform Scale

iphone scale multi-touch uitouch cgaffinetransform

I am transforming a view with CGAffineTransformMake. It rotates, scales and translates. This works just fine. But I cannot figure out a way to limit the scale to a maximum size.