Microsoft Ajax Minifier v4.47 minifies better than v5.14?

May 18, 2015 at 8:03 PM
Edited May 19, 2015 at 5:53 AM
I noticed that Microsoft Ajax Minifier v4.47 generates slightly smaller files than v5.14 in most cases. Here's sample code where this is the case:
function doTest(int) {
  var n = 0
      i = 0;
  if ((n!==95 && int===1) || (n!==0 && int===-1)) {
    i = 10;
    if (95-n<10 && int===1) i = 95-n;
    else if (n<10 && int===-1) i = n;
  } else {
    if (int===-1) {
      i = 95;
  return i;
Minified using v4.47 (133 bytes):
function doTest(n){var t=0;return i=0,t!==95&&n===1||t!==0&&n===-1?(i=10,95-t<10&&n===1?i=95-t:t<10&&n===-1&&(i=t)):n===-1&&(i=95),i}
Minified using v5.14 (148 characters):
function doTest(b){var a=0;i=0;if(a!==95&&b===1||a!==0&&b===-1){i=10;if(95-a<10&&b===1)i=95-a;else if(a<10&&b===-1)i=a}else if(b===-1)i=95;return i}
What are the reasons why this change was made in the later version? There doesn't seem to be a noticeable performance hit using the ||/?: pattern vs. the if/else pattern:

Is there a command-line switch in v5.14 that forces it to minify using the ||/?: pattern?

UPDATE: I just tried minifying jQuery 2.1.4, and here are the resulting file sizes (after stripping all comments and terminating with semicolon)...

v4.47: 84,679 bytes (82.6 KB)
v5.14: 86,300 bytes (84.2 KB)

Version 4.47 appears to be the size king if that's your most important criterion.
May 21, 2015 at 1:08 AM
Edited May 21, 2015 at 3:13 AM
So I copied the code above into a JS file and ran it through the latest sources (5.15 - they need a new release, apparently). I got this result:
Microsoft Ajax Minifier (version 5.15.5618.25160)
JavaScript and CSS minification and verification command-line utility
Copyright 2013 Microsoft Corporation

Minifying 'c:\test\l0basetom.js'

Original Size: 325 bytes; reduced size: 133 bytes (59.1% minification)
Gzip of source input approx. 167 bytes (48.6% compression)
Gzip of minified output approx. 121 bytes (62.8% compression)

function doTest(n){var t=0;return i=0,t!==95&&n===1||t!==0&&n===-1?(i=10,95-t<10&&n===1?i=95-t:t<10&&n===-1&&(i=t)):n===-1&&(i=95),i}
But there doesn't seem to be any outstanding check-ins that would affect the output of 5.14. Are you using any switches with 5.14? Or maybe the function you list is part of a larger file?
May 21, 2015 at 3:20 PM
Hi Ron,

I found the root cause of my insanity: unbeknownst to me, I had downloaded a very, very, very old version of AjaxMin.exe and put it in my 'utils' folder. My 'utils' folder happens to be earlier in the PATH than the folder where v5.14 was installed, so when I executed 'ajaxmin' it was actually calling that older version, not v5.14 (doh!).

This is also the same reason why I was getting all those errors when I tried to minify the CSS file. Sorry Ron if I wasted your time trying to help me. Now I feel like a dufus LOL.

May 21, 2015 at 4:03 PM
No problem at all; it happens to the best of us. Glad it was something so simple!

Dec 9, 2015 at 12:17 PM
i find a free online tool to minify javascript , it's easy to use.