The Closure Compiler comes in two flavors – a Java based command line tool and a RESTful API. I’ve been playing around with the API and it works great and very fast.
publicstring Compress(string file)
string source = File.ReadAllText(file);
XmlDocument xml = CallApi(source);
privatestaticXmlDocument CallApi(string source)
using (WebClient client = newWebClient())
string data = string.Format(PostData, HttpUtility.UrlEncode(source));
string result = client.UploadString(ApiEndpoint, data);
XmlDocument doc = newXmlDocument();
How to use it
GoogleClosure gc = newGoogleClosure();
string script = gc.Compress(Server.MapPath("~/script.js"));
Remember that the class doesn't do any exception handling, so you might want to stick that in yourself.