Monday, August 1, 2011

Ajax Minifier reduces the size of javascript and css files

Ajax Minifier is a Microsoft program which mifys js and css files. Minification is the process of reducing the size of a CSS or JS file by removing whitespaces, comments and other optimization. This is a free tool and it can be used in command line or MSBuild tasks.

The idea behind this tool is to improve the load time whenever the site is requested. Most of the times, about 70-90% of time spent waiting for a page on the average web site is actually due to the number of HTTP requests for images, JS and CSS files. To improve this, we can use this tool and it minify's the css, js files so that the download time will be considerably lesser than the actual file.

So whenever you trigger a new build from visual studio its going to execute a build and before moving that build to deployment server its going to execute this build task to minify and combine the css and javascript files in your site as mentioned by you in the target folder. After combining, its going to creat a single javascript and a single css file for entire site and name it with this version of build.

When the user requests for your site on the next time the name of previous js file and this js file is going to be different because of this version number change and the browser is going to download it to local cahe, so for subsequent requests it will use it from the cache. This is how it makes the site very faster.

No comments: