简体   繁体   English

SquishIt替换为short

[英]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.

相关问题 试图拆分 emdash(长破折号),但 dtm 不断将其替换为短破折号 - Trying to split emdash (long dash) but dtm keeps replacing it as the short dash 在Master页面中结合CSS和JS并使用SquishIt查看页面 - Combining CSS and JS in Master Pages and View Pages With SquishIt 用“ \\”代替 - Replacing “ with \” 有没有办法从SquishIt中的合并的javascript文件中删除哈希? - Is there a way to remove the hash from combined javascript files in SquishIt? 当最小化时,SquishIt JavaScript错误:&#39;missing; 声明前” - SquishIt javascript error when minimized: 'missing ; before statement' 在主体元素的末尾使用squishit并呈现外部minifiedjs - using squishit and rendering external minifiedjs at the end of body element 使用SquishIt缩小已经最小化的javascript是不好的做法吗? - Is it bad practise to use SquishIt to minify javascript which is already minifed? squishit给出304(未修改)而不是200(来自缓存) - squishit gives 304 (not modified) instead of 200 (from cache) SquishIt:如何从asp:ScriptManager中缩小asp.net默认主题中的CSS文件和Javascript文件? - SquishIt : How to minfy CSS files inside asp.net default theme and Javascript files from asp:ScriptManager? 尝试使用SquishIt合并.js文件时出现错误“ CS1026:预期” - Getting Error “CS1026: ) expected” when trying to combing .js files using SquishIt
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM