0

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?

Adrian Rosca
  • 6,922
  • 9
  • 40
  • 57

1 Answers1

0

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);
Richard Schneider
  • 34,944
  • 9
  • 57
  • 73
  • I know the method returns minfied code. That's not my problem. Clarified the question, thanx for pointing that out. – Adrian Rosca Aug 18 '15 at 06:56