Comparison of YUI Compressor for .Net to Microsoft Ajax Minifier


updated 8 years ago


Microsoft just released the Microsoft Ajax Minifier for minifying javascript files.  Since I've been using the Yahoo! UI Library: YUI Compressor for .Net to do this in AtomSite, I thought it would be great to compare the two to see which is best.  I'm mainly interested in the file size reduction but it would be nice to know any speed differences as well.

The Test


This method allows me to test compress some javascript using any method I pass into the Func delegate and capture the results.

To get a reasonable sample of the performance I minified 3 different files with each method 1000 times.  I attempted to configure both algorithms to produce the smallest output possible.


The Results


From these results you can see that Microsoft AJAX Minifier creates smaller files in about the same amount of time.  Note, both algorithms have been set in aggressive, or hypercrush, mode to rename variables and perform other tweaks for reducing file size. The Microsoft AJAX Minifier seemed to have more granular options for tweaking output. However, the YUI Compressor is open source so you could add additional options if you need them.

The Comparison

ScorecardSpeedSize ReductionOptionsBuild TaskOpen Source
YUI Compressorloseloselosewinwinwin
Microsoft AJAX Minifierwinwinwinlosewinlose

And the Winner is..

It depends.  I suggest using the Microsoft AJAX Minifier as it produces smaller files.  However, the YUI Compressor.Net better satisfies my needs as it can minify both JS and CSS files.  So, when I need to minify dynamic combinations of both types of files, I'll use Yahoo! UI Library: Compressor for .Net.  When I need to do one-time minification during a build or prior to deployment, I'll use the Microsoft AJAX Minifier.


I've uploaded the test solution and console app so you can run the tests yourself. (291KB) fixed

More Reads

Check out how I am using minification and combination in AtomSite to speed up page load time.