Minifies all JavaScript files in a given directory and writes out the minified files to a new file extensions (.min.js for example).

This method can be integrated into the build process, or as part of an application's startup to always create new minified scripts as needed. Scripts are only minified if the minified files don't already exist and are older than the corresponding JavaScript file.

A common usage scenario is to call this static method from Application_Start:

void Application_Start(object sender, EventArgs e) { // creates minify scripts if don't exist or are changed // NOTE: REQUIRES that IIS/ASP.NET Account has writes to write here! Westwind.Web.Controls.JavaScriptMinifier.MinifyDirectory(Server.MapPath("~/ scripts"), ".min.js", true); }

to always ensure minified files are in sync with corresponding JavaScript files.