public string MinifyJavaScript(string source); public string MinifyJavaScript(string source, CodeSettings settings);
function foo(a) { a.b = 12345; a.c = 12345; a.d = 12345; a.e = 12345; }
function foo(a) { var b=12345; a.b=b; a.c=b; a.d=b; a.e=b }
// create the parser from the source string. // pass null for the assumed globals array JSParser parser = new JSParser( source, null ); string minified; // hook the engine error event parser.CompilerError += new CompilerErrorHandler(OnCompilerError); try { // parse the input Block scriptBlock = parser.Parse(settings); if (scriptBlock != null) { // we'll return the minified code minified = scriptBlock.ToCode(); } } catch(JScriptException e) { // other error handling }
public string MinifyStyleSheet(string source); public string MinifyStyleSheet(string source, CssSettings settings);
CssParser parser = new CssParser(); parser.CssError += new EventHandler<CssErrorEventArgs>(OnCssError); parser.FileContext = sourceFileName; string crunchedStyles = parser.Parse(source);