Microsoft Ajax Minifier doesn't shorten my function names

257 Views Asked by At

I declare the following javascript

window.myApp = {};
myApp.myVeryLongFunctionName = function()
{
    ...
};

Then I minify the javascript with the following (in C#)

var minifiedCode = minifier.MinifyJavaScript(code, new CodeSettings
{
    RemoveUnneededCode = true,
    PreserveImportantComments = false,
    LocalRenaming = LocalRenaming.CrunchAll,
    EvalTreatment = EvalTreatment.MakeAllSafe,
    OutputMode = OutputMode.SingleLine,
    PreserveFunctionNames = false                        
});

But "myApp" and "veryLongFunctionName" doesn't get shorted, it gets minfied to this.

window.myApp={};myApp.myVeryLongFunctionName=function(){};

I would the code to be minified to something like this.

window.a={};a.b=function(){};

What code settings parameters do I need to achieve this?

1

There are 1 best solutions below

1
On

MinifyJavaScript() returns the minified code as a string. Try this:

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);