I've downloaded Yahoo JavaScript Uglify (yuglify) from https://github.com/yui/yuglify and I intent to use it for JS and CSS compression on some PHP projects hosted on a apache server. Tried to minify a file with these original contents:
var _cmFrameList = new Array (); // a pool of reusable iframes
var _cmFrameListSize = 0; // keep track of the actual size
var _cmFrameIDCount = 0; // keep track of the frame id
var _cmFrameMasking = true; // use the frame masking
// disable iframe masking for IE7
/*@cc_on
@if (@_jscript_version >= 5.6)
if (_cmFrameMasking)
{
var v = navigator.appVersion;
var i = v.indexOf ("MSIE ");
if (i >= 0)
{
if (parseInt (navigator.appVersion.substring (i + 5)) >= 7)
_cmFrameMasking = false;
}
}
@end
@*/
var _cmClicked = false; // for onClick
But got this instead:
var _cmFrameList=new Array,_cmFrameListSize=0,_cmFrameIDCount=0,_cmFrameMasking=!0,_cmClicked=!1
In the contents of the original file, there's some conditional compilation code that's needed to work on older IE browsers (commented lines starting with @cc_on, @if, @end, etc). It seems that yuglify is treating these conditional compilation lines as simple comments, and as such, is removing all of it.
By curiosity, I've tested yuicompressor on this same file too ( https://github.com/yui/yuicompressor/downloads ), and it seems that all conditional compilation code is intact. Even the linebreaks are still there:
var _cmFrameList=new Array();var _cmFrameListSize=0;var _cmFrameIDCount=0;var _cmFrameMasking=true;
/*@cc_on
@if (@_jscript_version >= 5.6)
if (_cmFrameMasking)
{
var v = navigator.appVersion;
var i = v.indexOf ("MSIE ");
if (i >= 0)
{
if (parseInt (navigator.appVersion.substring (i + 5)) >= 7)
_cmFrameMasking = false;
}
}
@end
@*/
var _cmClicked=false;
Older IE browsers gets garbled without those conditional compilation lines. Is it possible to use yuglify without removing it?