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. -- remove spaces in JavaScript code

  2. -- in addition to removing spaces and new line characters, this tool renames variables to shorter ones, and uses other techniques to compresses the file.



Comments (2)

  1. Ravi Terala says:

    Wouldn’t using http gzip compression be better?

  2. Craig Humphrey says:

    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!



Skip to main content