Welcome to MSDN Blogs Sign in | Join | Help

SYSK 297: Condense JavaScript Code for Faster Download

Did you notice that Microsoft AJAX library JavaScript files come packaged as release and debug files; e.g. MicrosoftAjax.js and MicrosoftAjax.debug, MicrosoftAjaxWebForms.js and MicrosoftAjaxWebForms.debug.js, etc?

 

One of the differences is that the release version of the file has no extra spaces, which results in smaller file size, and, consequently, faster download for customers.

 

There are a couple of tools that come to mind for this purpose:

  1. http://www.cfoster.net/jscrunch/ -- remove spaces in JavaScript code
  2. http://alex.dojotoolkit.org/shrinksafe/ -- in addition to removing spaces and new line characters, this tool renames variables to shorter ones, and uses other techniques to compresses the file.

 

 

Published Wednesday, February 28, 2007 6:31 AM by irenak
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: SYSK 297: Condense JavaScript Code for Faster Download

Wednesday, February 28, 2007 12:40 PM by Ravi Terala

Wouldn't using http gzip compression be better?

# re: SYSK 297: Condense JavaScript Code for Faster Download

Wednesday, February 28, 2007 8:11 PM by CraigHumphrey

I agree, given that all your .js files are basically static, they're ideal candidates for compression via IIS.

After all, gzip is going to get way more compression than any variable renaming and whitespace stripping.

OK, so there are a few browsers out there that still don't support compression, but then they're probably going to struggle with AJAXy pages anyway.

Just my 2c.

Roll on AJAX for SharePoint2007!

Later'ish

Craig

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker