.net, c#, asp.net, linq, htpc, woodworking

Comparison of YUI Compressor for .Net to Microsoft Ajax Minifier

Posted in jQuery, ASP.NET by JarrettV on 10/19/2009 11:57:04 PM - CST


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

Scorecard Speed Size Reduction Options CSS & JS Support Build Task Open Source
YUI Compressor lose lose lose win win win
Microsoft AJAX Minifier win win win lose win lose

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.

JsMinTest.zip (291KB) fixed

More Reads

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


Posted by aron on 11/9/2009 9:18:09 AM - CST
Hello, link is broken: JsMinifyTest.zip (291KB)
Posted by JarrettV on 11/19/2009 10:35:44 AM - CST
hey aron, fixed link

Add Comment

Login using
and more
Or provide your details
Please enter your name. Please enter a valid email. Please enter a valid website.
Please supply a comment.
4.0 (2)
on 11/19/2009 10:35:24 AM - CST

Recent Entries

Valid XHTML 1.0 Strict
© Copyright 2024