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.

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

2 Comments

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.
@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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.