So I was just minifying using the AjaxMin.dll in my project on every build/deployment for all js/css files with the default settings. This turned out to be a bad idea. One of the third party javascript files that we have has a nice eval statement with some variables or parameters being referenced. When it gets minified, the original variables get renamed and not renamed in the eval statement. This has caused a big old error in production (F开发者_如何学JAVAML).
I have decided I need to pick safer settings for the minification process.
The documentation on AjaxMin is very ummm not clear. http://www.asp.net/ajaxlibrary/AjaxMinWithAndEval.ashx
Or maybe i just don't understand it. I am using the code (with the DLL) and not the command line.
The CodeSettings
class has a EvalTreatment
class option but I am unsure what is the best option to pick...
From Microsoft (DLL source):
using System;
namespace Microsoft.Ajax.Utilities
{
public enum EvalTreatment
{
Ignore = 0,
MakeImmediateSafe = 1,
MakeAllSafe = 2,
}
}
I am thinking MakeImmediateSafe
(1) or MakeAllSafe
(2)? What do you guys think?
Thanks in advance!
If you want to make absolutely sure the minified results will always work, use the MakeAllSafe option. That will ensure no variables in the scope of the eval statement, nor in any parent scopes, will be renamed.
精彩评论