阿贾克斯Minifier(AjaxMin) - EvalTreatment对JavaScript? [英] Ajax Minifier (AjaxMin) - EvalTreatment for JavaScript?

查看:142
本文介绍了阿贾克斯Minifier(AjaxMin) - EvalTreatment对JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我只是污染减量使用AjaxMin.dll在我的每一个构建/部署与默认所有的JS / CSS文件设置项目。事实证明,这是一个坏主意。一,我们有有一些变量或参数的一个很好的eval语句第三方JavaScript文件被引用。当它被缩小的,原始变量获得改名和eval语句不重命名。这导致在生产(FML),一个大的老错误。

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 (FML).

我决定我需要选择更安全的设置微小的过程。

I have decided I need to pick safer settings for the minification process.

在AjaxMin的文档是非常嗯尚不清楚。 http://www.asp.net/ajaxlibrary/AjaxMinWithAndEval.ashx

The documentation on AjaxMin is very ummm not clear. http://www.asp.net/ajaxlibrary/AjaxMinWithAndEval.ashx

或者,也许我只是不明白。我现在用的是code(使用DLL),而不是命令行。

Or maybe i just don't understand it. I am using the code (with the DLL) and not the command line.

codeSettings 类有一个 EvalTreatment 类选项,但我不能确定什么是最好的选择挑...

The CodeSettings class has a EvalTreatment class option but I am unsure what is the best option to pick...

从微软(DLL源):

using System;

namespace Microsoft.Ajax.Utilities
{
    public enum EvalTreatment
    {
        Ignore = 0,
        MakeImmediateSafe = 1,
        MakeAllSafe = 2,
    }
}

我想 MakeImmediateSafe (1)或者 MakeAllSafe (2)?你们有什么感想?

I am thinking MakeImmediateSafe(1) or MakeAllSafe(2)? What do you guys think?

在此先感谢!

推荐答案

如果你想的绝对保证的该缩小的结果的总是的工作,使用 MakeAllSafe 选项。这将确保没有变量的eval语句的范围,也没有在任何父范围,将其改名。

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.

这篇关于阿贾克斯Minifier(AjaxMin) - EvalTreatment对JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆