ScriptResource.axd from Ajax getting Too Big

Today I was testing the loading time of my site, which I sometimes find it slow to access especially the first time loading. I knew there are a lot of images to be loaded especially those in portfolio sections but I also found that the biggest loading item seems to be ScriptResource.axd from Ajax. It was 330kb!

So, I did a little big of Google, and found this out:

There are two options:

1- Specify the property “scriptpath” of the ScriptManager object with the path where you have the folder “\System.Web.Extensions” with all the Js files. (Ex: “~/Jscript”).

In this case the page will be too big to load in the browser because the files “MicrosoftAjax.js” and “MicrosoftAjaxWebForms.js” will be completely loaded with the page.

If you have the property “scriptmode” = release, then the files will have 80KB plus 20KB. With “scriptmode” = debug the files will have 250KB plus 60KB. If you have cache for Js in the browser its OK and the first time the page is loaded will take much longer.

2- You leave “scriptpath” empty and the AJAX will generate only the javascript that is needed like this: ScriptResource.axd?d=3dNkxltjv-1JPul9EiKw4KGad ……and it will have just 1024 bytes plus 1024 bytes and in this case you will have no cache for this javascript.

Read: The Web Page Is Too Big After Use Ajax Control Toolkit

Categories: ASP.NET, C#
Tags: