Sunday, December 2, 2012

[C#] Minimizing and optimizing .js in .NET (pre-4.5) - Google Closure API

Google Closure helps you minimize and optimize multiple .JS files into one file.

You can turn this code

function hello(name) {
  alert('Hello, ' + name);
hello('New user');

Into this code

function hello(a){alert("Hello, "+a)}hello("New user");

To be noted: If you're using ASP.NET 4.5 we already have this functionality out of the box:

But I made a simple library for interacting with the Google Closure API

Source paste
Project and test


using GoogleClosureHelper;

ClosureHelper.InputFolder = "JSFolder";
ClosureHelper.OutputFile = "Compiled.js";
ClosureHelper.CompileToOutputPath("SIMPLE_OPTIMIZATIONS", "text", "compiled_code");

Look here for the parameters:

Web interface:

No comments:

Post a Comment