Automatically minify and combine JavaScript and CSS files in any web site
page 2 of 8
by Matt Perdeck
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 55395/ 194

How it works 

In a nutshell, the CombineAndMinify package contains two components:  

An adapter for the ASP.NET Head control

When you use runat=“server” in your head tag, ASP.NET represents the head of your page as an HtmlHead control. ASP.NET allows you to determine how each control is converted to HTML by writing a so called adapter. Adapters were originally introduced to allow developers to generate browser specific code for a given control,  but here it is used to rework the  head section of your page.  

The adapter is used to replace the tags that load individual JavaScript and CSS files by tags that load the combined files. If you configured the CombineAndMinify package to insert version ids in image urls or to remove white space, the adapter goes through the rest of the page to make that happen as well.    

An HTTP Handler to process JavaScript, CSS and image files

ASP.NET allows you to write HTTP Handler to do your own processing of for example JavaScript files.  The HTTP Handler included in the CombineAndMinify package is used to combine and minify JavaScript and CSS files. It caches the resulting files to save CPU cycles. Using file dependencies, the cache entries are invalidated the moment any of the files are updated, so you never serve outdated files.  

When you choose to insert version ids in image urls, the HTTP Handler is also used to strip the version ids out of incoming requests for images and to serve the images themselves. It also generates the HTTP response header to allow the browser to cache the image for up to a year.   

View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2019  |  Page Processed at 2019-08-19 8:56:40 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search