You are here > Blog
Mar 2

Written by: Chris L Bennett
3/2/2010 1:28 AM  RssIcon

For some time, I’ve always had an interest in performance optimizations and just better ways to do things.  I look at both the code behind as well as optimizations to improve the browsing experience, such as using CSS sprites.  The other day, I started wondering if a) this module already exists and b) if not, would it be possible to create.  Basically, my idea would be to create an ASP.Net Module which would be used to provide a starting point to optimize both the JavaScript and CSS files for a site on the fly. 

To start with, the module would be used to cut down on the number of requests needed by combing all JavaScript and CSS references on the page down to a single request each.  If you’ve used something like Yahoo User Interface (YUI) or even jQuery the number of files needed for the base library plus all of the code for the site start to impact the experience for the user.  After reducing the number of requests, made by the browser, we would add code to utilize a minify tool such as JSMIN or the new Google Closure compiler to reduce the code size.  I’m thinking it would be a good idea to provide flexibility to allow for swapping out of the minify engine used for flexibility.  So in the end, it would cut down on the number of requests and reduced the bandwidth necessary to transfer them.  Depending on the design and the complexity of the site, this can have a huge impact. 

In creating the module, I think ASP.Net already has hooks available to make the JavaScript side easier to implement; however, I’m not 100% about the CSS side.  Even if they don’t exist, the module could pull out the appropriate tags, combine the results, through most likely a handler, and update the markup on the way to browser.  Ideally, it would be useful to keep the process transparent so the module could be used to improve existing code and the markup, allowing it to be used across a wide range of projects such as DotNetNuke.  Eventually, it may be possible to include inline JavaScript and CSS in the processing; however, that presents a far more complex algorithm to extract, minify and replace.

Telerik does have a control which can perform some of this by replacing the ScriptManager; however, since it is not transparent the source code needs to be modified to take advantage.  Not to mention the licensing cost.  I’m not sure if there are any other commercial and/or open source projects with close to this functionality.  If they do exist, can someone help out there?  And I’m thinking this would be a good Codeplex project for collaboration, and for visibility.

Let me know if you think this a good idea and or if you have any thoughts on the implementation.  If you would like to be involved, let me know as well.  If this looks like a good idea, per feedback, I don’t mind to create the Codeplex project and coordinate. 

Comments appreciated

1 comment(s) so far...


Gravatar

Re: ASP.Net JavaScript/CSS Optimization Module Idea

Interesting post!


It is very informative.

Thanks!

By Fulltime ASP net developers on   6/15/2010 12:32 AM

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
CAPTCHA image
Enter the code shown above in the box below
Add Comment   Cancel