[英]SquishIt replacing with short
I'm using 9.8.0 latest stable framework of SquishIt . 我正在使用9.8.0最新的SquishIt稳定框架。
Problem with javascript minify. javascript缩小问题。 When it minify long variables like function(imReallyLong) to function(n) 当它运行如下长变量,如函数(imReallyLong) 以 功能(N)
This is ok for minify but only if you are not using eval()! 这样做可以缩小,但前提是您不使用eval()!
My method was: 我的方法是:
Fire: function (jDto) {
var sectionName = Enum.Parse(Enum.SectionID, jDto.SectionID);
eval('Section.Init.' + sectionName + '(jDto)');
},
After minify: 缩小后:
Fire: function (n) {
var t = Enum.Parse(Enum.SectionID, n.SectionID);
eval("Section.Init."+t+"(jDto)")
},
The problem jDto variable. 问题jDto变量。 It is hard coded as string and SquishIt can't know it. 它被硬编码为字符串和Squish它不知道。
Is it possible to prevent changing variables option or something like that? 是否可以防止更改变量选项或类似的东西? Or more cool framework? 还是更酷的框架?
Thank you. 谢谢。
This is minifier behavior, not squishit. 这是minifier行为,而不是卑鄙的行为。
I think you might be able to work around it with the MS Minifier using something like this ( Ajax Minifier (AjaxMin) - EvalTreatment for JavaScript? ): 我认为您可以使用这样的东西(如Ajax Minifier(AjaxMin)-EvalTreatment for JavaScript? )与MS Minifier一起解决:
.WithMinifier(new MsMinifier(new CodeSettings { EvalTreatment = EvalTreatment.MakeAllSafe }))
There is an ignoreEval option for YUI minifier that looks like it allows functions calling eval to be compressed ( https://github.com/BillyChan501/YUI-Compressor-.NET/blob/master/Projects/Yahoo.Yui.Compressor/Model%20Tests/JavaScriptCompressorTest.cs#L218-L256 ). YUI缩小器有一个ignoreEval选项,它看起来像允许对调用eval的函数进行压缩的方式( https://github.com/BillyChan501/YUI-Compressor-.NET/blob/master/Projects/Yahoo.Yui.Compressor/Model %20Tests / JavaScriptCompressorTest.cs#L218-L256 )。 So the example you have might "just work" using default YUI options for minification? 因此,您使用默认的YUI选项进行压缩的示例可能“正常工作”?
.WithMinifier<YuiMinifier>()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.