我宣布以下javascript
window.myApp = {};
myApp.myVeryLongFunctionName = function()
{
...
};
然后我用以下(在C#中)缩小javascript
var minifiedCode = minifier.MinifyJavaScript(code, new CodeSettings
{
RemoveUnneededCode = true,
PreserveImportantComments = false,
LocalRenaming = LocalRenaming.CrunchAll,
EvalTreatment = EvalTreatment.MakeAllSafe,
OutputMode = OutputMode.SingleLine,
PreserveFunctionNames = false
});
但是“myApp”和“veryLongFunctionName”不会短路,它会被搞砸。
window.myApp={};myApp.myVeryLongFunctionName=function(){};
我会将代码缩小为类似的东西。
window.a={};a.b=function(){};
实现此目的需要哪些代码设置参数?
答案 0 :(得分:0)
MinifyJavaScript()
将缩小的代码作为字符串返回。试试这个:
var s = minifier.MinifyJavaScript(code, new CodeSettings
{
RemoveUnneededCode = true,
PreserveImportantComments = false,
LocalRenaming = LocalRenaming.CrunchAll,
EvalTreatment = EvalTreatment.MakeAllSafe,
OutputMode = OutputMode.SingleLine,
PreserveFunctionNames = false
});
Console.WriteLine(s);