Welcome to AspAdvice Sign in | Join | Help

ASP.NET AJAX Download Performance Improvement Request

I'm a big fan of ASP.NET AJAX in general, but one concern I have and something that has forced me to use other technologies is the size of the library.  It's about 85kb when compressed and unfortunately that is quite large if you're trying to include it on most every page on a site (or, much much worse, every advertisement in a large Microsoft developer advertising network).  One can certainly argue that this will be cached, and that is true, but for many sites that get most of their traffic from search engines (ASPAlliance gets over 70% of its traffic from this), you have to assume that many users will not have the .js file cached, and that is a significant increase in the total page size.

I would like to suggest (and have done so previously, but less publicly) that it would be a good thing if the ASP.NET AJAX javascript library were hosted by Microsoft as an option.  This would involve some slight changes to the coding (specifically I would add a property to the <ScriptManager> control to enable using the Microsoft provided library), and would require that Microsoft make a commitment to having the .js file available via their infrastructure.  In practice this would not be very different from the distribution model that they are currently using for Silverlight deployment, but would be much smaller (per file - 85kb vs 4mb).

The chief advantage of this approach would be a huge reduction in the number of downloads of the AJAX javascript file required for clients, and an increase in performance across the board as a consequence.  The likelihood that any given browser would have a cached version of the AJAX javascript would be much higher if a large number of AJAX-enabled sites referenced the Microsoft hosted AJAX library.  The cost (in bandwidth) to use AJAX would go down.  The performance for all AJAX-enabled web applications would go up.  Clients that do not wish to cede control of the distribution of the download could continue hosting the files themselves without any change.  The change in behavior of ScriptManager could easily be rolled out in an SP or as part of vNext, and would make AJAX more attractive when compared to alternate (lighter weight) JavaScript frameworks such as jQuery.

Published Tuesday, April 15, 2008 2:38 PM by ssmith
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: ASP.NET AJAX Download Performance Improvement Request

Although "lighter" than the MS AJAX library, I wouldn't call jQuery "light."  Regardless, this is an excellent idea that would benefit sites that use the library and remove an obstacle (for some) in adopting it.  A Versioning scheme would need to be worked out, but there is very little downside to it (besides the increased bandwidth costs, if there are any, incurred by MS.)

Tuesday, April 15, 2008 4:11 PM by Carl

# re: ASP.NET AJAX Download Performance Improvement Request

I completely agree with you.  I was more or less forced to use Mootools with JQuery just because the generated scripts of the MS Ajax library and the Ajax toolkit were just huuuuuuuuuge.  Even worse, I've noticed, that they script files don't always get cached (even on the same browser).  Is that due to the way they're generated dynamically by a HTTPHandler??

Either way, I haven't looked back after switching to JQuery.  MS Ajax is cool but it's bulky size doesn't make it a good option for Internet sites (just fine for Intranet though).

Tuesday, April 15, 2008 5:18 PM by Arash Homayounpour

# re: ASP.NET AJAX Download Performance Improvement Request

I agree.

My todo list includes removing ASP.NET AJAX from one of my public-facing sites soon.  It kills the initial load speed for the site, reducing my quality score in various ad networks and increasing the bounce rate of impatient first time visitors.

If I could deploy ASP.NET AJAX backed by a Microsoft CDN, it would suddenly be much more competitive against something like jQuery.

@Arash:  Make sure you have the ScriptManager's ScriptMode=Release, and have this line in your web.config:

<scriptResourceHandler enableCaching="true" enableCompression="true" />

Tuesday, April 15, 2008 6:25 PM by Dave

# re: ASP.NET AJAX Download Performance Improvement Request

I wonder how quickly Microsoft would come around and make the change to host it if someone else started hosting it... like say Google?

Tuesday, April 15, 2008 10:25 PM by Erik

# re: ASP.NET AJAX Download Performance Improvement Request

Great idea.  Yahoo does this with their code library, and they maintain strict version numbers for each release -- and keep them all available.  So even if the code gets updated -- and it frequently does -- nothing breaks on the web, since every web page links to a version of the code.

Tuesday, April 15, 2008 11:56 PM by Speednet

# Interesting Finds: April 16, 2008

Wednesday, April 16, 2008 10:17 AM by Jason Haley

# re: ASP.NET AJAX Download Performance Improvement Request

Will this not result in a cross-site-scripting security issue?
Thursday, April 17, 2008 7:36 AM by Peter

# re: ASP.NET AJAX Download Performance Improvement Request

@Peter,

 Yes, it will not result in a xss issue.  There are plenty of sites out there that host JS files from other locations - look at Google Analytics and just about every advertising platform out there, including Lake Quincy Media's.  And as others have mentioned, several other third party javascript libraries follow this design already, including Yahoo.  What issue, specifically, do you anticipate?

Thursday, April 17, 2008 4:17 PM by ssmith

# Improved Search Engine Placement

Increasing traffic to your website should be the first priority of eveyrthing.

Saturday, April 19, 2008 4:29 PM by Improved Search Engine Placement

# re: ASP.NET AJAX Download Performance Improvement Request

One "major" issue would be the assumption a user of your site would always have connection to both Microsoft's servers and yours at the same time.

While it is getting less and less likely nowadays, the Internet is still a highly dynamic place with routes going up and down all the time. There can, and will, be incidents where one may not be able to properly route to a Microsoft web server for obtaining the necessary javascript files. I have seen this happening before.

And when it happens, your AJAX implementation may be toast.

Wednesday, May 28, 2008 12:21 AM by Aaron Seet

# re: ASP.NET AJAX Download Performance Improvement Request

@Aaron,

Of course, that's why it would only be an option.  A flag you could set in web.config or on the ScriptManager control.  It would be your choice if you thought your app was so mission critical that it couldn't have a dependency on Microsoft's Content Delivery Network.  Or you could simply monitor that CDN and fail over to your own script files if it became non-responsive.  Not hard.

Sunday, June 01, 2008 3:56 PM by ssmith

# re: ASP.NET AJAX Download Performance Improvement Request

Working on it. But you got the size of the framework wrong. The release version of MicrosoftAjax.js is 22kB gzipped. Not sure where you got that 85kB figure.

Wednesday, December 10, 2008 2:52 AM by Bertrand Le Roy

# re: ASP.NET AJAX Download Performance Improvement Request

@Bleroy,

 That's what FireBug reported in August 2007.  I don't recall at this point if this was perhaps a pre-release version but most likely it was simply showing the un-zipped size of the file.  In any event, for my purposes, it was a TON more bandwidth than I wanted to pay for to use the file, since all I needed was a small fraction of the full library (and my current script is about 4000 bytes).

Wednesday, December 10, 2008 12:58 PM by ssmith

Leave a Comment

(required) 
required 
(required) 
Enter the code you see below