Welcome to Bilal Haidar [MVP, MCT] Official Blog Sign in | Join | Help

ASP.NET AJAX's CompositeScript in .NET 3.5 SP 1

The .NET 3,5 SP1 adds several features to the .NET products. One of the major improvements in my opinion regarding the ASP.NET AJAX 3.5 is the CompositeScript.

Usually, when you place a ScriptManager instance on the page, you include several scripts and you place them within the Scripts class collection. This means, if you had like 5 scripts to load, you will have 5 different calls to the server to request the 5 script files.

The improvement in .NET 3.5 SP1 is the addition of the CompositeScript class that allows you to group a collection of script files and have them rendered to the cllient as a single script file and hence instead of requesting 5 script files (according to the example above), you will be requesting a single script and hence minimized the requests to server from 5 to 1.

<asp:ScriptManager ID="ScriptManager1" runat="server">
<CompositeScript>
<Scripts>
<asp:ScriptReference Path="~/Scripts/Script1.js" />
<asp:ScriptReference Path="~/Scripts/Script3.js" />
</Scripts>
</CompositeScript>
</asp:ScriptManager>

 As you can see this has a great improvement in performance since less requests will be issued to the server.

 

Regards

 

Published Saturday, November 15, 2008 11:28 PM by BilalHaidar [MVP]

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's CompositeScript in .NET 3.5 SP 1

I am really really not sure about performance gains...

1st. It takes a CPU power to combine those scripts. So someone need to measure what is cheaper (in terms of CPU utilization). Combining 5 scripts into 1 or keep things old way and allow 5 request to the server.

Or if you talking about Client side performance utilization it's not clear as well....

The download time will be the same for Script1,Script2 vs Script1 + Script2. So we only win the time to do the actual call which is not much.

Plus let say I have 2 pages.

And one using Script1.js (100Kb), and Script2.js (30Kb) and another using Scrip1.js and Script2.js and script3.js (2kb)

Script1 and Script2 cached on a client. So browser only need Script3 which is only 2kb. And by combining it into one we make it download all 132Kb again.

Keep in mind that this described scenario is the usual one.

I have JQuery.js and some other helper library on all pages... And then each page loads up small .js file that needed for that particular feature on the page (like Calendar for example).

Tuesday, November 18, 2008 12:03 PM by George Ter-Saakov

Leave a Comment

(required) 
required 
(required)