When you use IIS 7.0来 to host your site on a Windows server, you can configure IIS to automatically compress your JavaScript files using the gzip compression algorithm, which provides significant improvements in performance and file download sizes. However, you can get additional performance benefits by compressing and narrowing (minifying) your JavaScript files at the same time. Steve Sounders in his excellent books
The following is a reduced JavaScript file with Microsoft Ajax Minifier (Super Flattening level enabled):
Note that all unnecessary whitespace is removed, and note that the parameter firstvalue and secondvalue of the function are renamed B and a.
The Microsoft Ajax minifier Download contains the following components:
- ajaxmin.exe– command line tools to shrink JavaScript files
- ajaxmintask.dll– the MSBuild task of a JavaScript file in a Visual Studio project
- ajaxmin.dll– components that can be used to shrink JavaScript files in C # or vb.net applications
After installing Microsoft Ajax Minifier, you can use the Microsoft Ajax Minifier command-line tool to shrink JavaScript files on the console command line.
You can also choose to add Microsoft Ajax Minifier as a custom MSBuild task to Visual Studio. Add the MSBuild task to your Visual Studio project file, allowing you to automatically shrink all JavaScript files at any time, allowing you to zoom out in an automated manner.