Wednesday, May 14, 2008

Increase AJAX Performance by using Composite Script

As you can see in Web Developer tool, there is a lot of request happening on the background.

The first thing you need to do before combining Ajax scripts, You need to know what scripts are being used by your pages.

Add this on your pages to detect what scripts are being used.

<microsoft:ScriptReferenceProfiler runat="server"/>



After that Copy all the Script References which is written by Script Reference Profiler.



And Paste it into Script Manager Composite Scripts.




<asp:ScriptManager runat="server">
<CompositeScript>
<!-- Paste Here -->
<asp:ScriptReference name="~/Scripts/MyCustomScripts.js"/>
<asp:ScriptReference name="MicrosoftAjax.js"/>
<asp:ScriptReference name="MicrosoftAjaxWebForms.js"/>
....
....
<!-- -->
</CompositeScript>
</asp:ScriptManager>



And as a results you can decrease the number of request and traffic for this scripts.

PS: The ScriptReferenceProfiler control is not part of the Beta installation, and you must install it separately. Download this http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=aspnet&ReleaseId=13356.

1 comment:

DFGasner said...

Just wondering if anyone else has had an issue with this CompositeScript only allowing 30 scripts and any over that there starts to be AJAX errors on runtime?

Davey