1

Google Page Speed is saying we should combine external JavaScript. Fair enough.

I know that the way to do this is to use a CompositeScript tag inside asp:ScriptManager.

<asp:ScriptManager runat="server">
   <CompositeScript>
      <Scripts>
         <asp:ScriptReference Name="AjaxControlToolkit.Common.Common.js" Assembly="AjaxControlToolkit" />
         <asp:ScriptReference Name="AjaxControlToolkit.Calendar.CalendarBehavior.js" Assembly="AjaxControlToolkit" />
         < ... />
      </Scripts>
    </CompositeScript>
</asp:ScriptManager>

What I don't know is which script references to add. In my page I have lots of

<script src="/ScriptResource.axd?d=big-string-here" type="text/javascript"></script>

How do I discover what <asp:ScriptReference Name="x" Assembly="Y" /> tags I should add to the CompositeScript tag?

There's a usercontrol out there with this specific aim, and we even have already used it before, but I can't find it again o Google.


EDIT

The usercontrol I was looking for is ScriptReferenceProfiler. How to use it.
I still accepted the answer bellow because it may help someone else in the same situation.

tiago2014
  • 3,392
  • 1
  • 21
  • 28

1 Answers1

1

I believe if you use AJAX Toolkit's ToolkitScriptManager then it would anyway combine all ScriptResource and WebResource scripts by default (you need not have to mention these). See these related posts: How do I combine WebResource.axd and ScriptResource.axd files so as to result in less requests to my ASP.NET server?

In .NET4, ScriptManager should also able to do the same: http://www.hanselman.com/blog/ASPNETAjaxScriptCombiningAndMovingScriptResourceaxdsToStaticScripts.aspx

Community
  • 1
  • 1
VinayC
  • 47,395
  • 5
  • 59
  • 72
  • Thanks for your answer. It's a great point and good advice, but it do not answer the asked question. I tried ToolkitScriptManager but unfortunately it was incompatible with something else. – tiago2014 Mar 09 '11 at 20:18
  • @tiagoniu, I understand that its not answer to your specific question (but I believe that it solves the actual problem) - the issue with adding script resources & web resources manually is not actually about the discovery of resources being used but its more about maintenance - what if new version of control comes up that uses different set of resources or new control has been added to page etc. A full proof solution would involve discovery of registered script resources - thats exactly is happening in above solutions. – VinayC Mar 10 '11 at 04:04