When response is generated by server, it contains unnecessary text like tabs, spaces and new line characters. This library will remove all these unnecessary text
with minifying in single line. It will reduce the page size as well. This library will minify the HTML and CSS content.
How to use it?
It is easy to use this library. Download the MinifyContent library source project. Build the project in release mode. Add reference of MinifyContent.dll in the Asp.Net web application.
Once the dll has been added to the project, register the ContentCompresser module in web.config file. This HTTP Module is responsible to minify
That’s all. It’s time to run the application now. Once the page has been loaded in browser, verify the HTML contents.
Opps!!! The HTML contents are not minified, are we missing something?
the HTML contents. So what to do to minify it? Simple, for now just change the execution mode of application from Debug to Release; from Standard toolbar or from Configuration Manager
screen. Now run the application and verify the HTML contents once the page has been loaded in browser.
Are the Contents minified this time?
No. What’s wrong now?
It should minify this time as the web application has been run in Release mode!!!
Check the web.config file. Under System.web section group, in Compilation Section; check the value of debug attribute. If it is true, change the value to false.
All is completed and run the application now. Observe that contents are minified.
Some statistics of minified default.aspx page.
||Size in Bytes
|Difference in %
Points of Interest
- Why debug value should be false in web.config file with Release Mode? Refer the following URLs:
- At the time of testing, QA can verify that the application has been published in release mode with debug value false, which helps to identify application
published mode prior to deployment on production server.
- 19th July, 2012: Initial post.