O'Reilly logo

Professional ASP.NET 3.5 AJAX by Matt Gibbs, Dan Wahlin, Bill Evjen, Dave Reed

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

5.4. Customizing the Location of Scripts

You've seen how you can provide Release and Debug versions of JavaScript files on disk, and the ScriptManager will automatically reference the correct version. And you've seen how to embed scripts in a .dll for easier servicing. ASP.NET AJAX also allows you to further customize script reference behavior.

5.4.1. Setting the Script Path

You may want to put the common scripts for nested applications in a single location to allow the browser to cache a single copy for multiple directories. Typically, ASP.NET AJAX returns relative path references for embedded script resources, so the browser can end up caching multiple copies of a script for different applications within the same domain. The ScriptManager's ScriptPath property allows you to define a path to use in lieu of the normal discovery process. This allows you to put the scripts in a single location and have all references in the domain refer to that location. This also has a performance benefit, because it is faster to load a static JavaScript file from disk than to extract it from an assembly through the ScriptResource.axd handler.

At first, this may not seem like much, but when you consider that, even compressed, the amount of script to enable ASP.NET AJAX scenarios is more than 10K, allowing each user to get just one copy instead of one for each subdomain or nested application can really add up. The perceived performance for the user in eliminating excess calls can be significant. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required