This is a migrated thread and some comments may be shown as answers.

RadScriptManager question

5 Answers 607 Views
ScriptManager and StyleSheetManager
This is a migrated thread and some comments may be shown as answers.
Carl Sconnely
Top achievements
Rank 1
Carl Sconnely asked on 23 Jan 2012, 03:24 PM
Hi

I am using RadScriptmanager to combine all the javascript on the page into a single call but it still generates telerik system javascript files.

<telerik:RadScriptManager ID="rsMan" runat="server"
      OutputCompression="Forced" EnableScriptCombine="true" ScriptMode="Auto">
      
      <CompositeScript>
          <Scripts>
           <asp:ScriptReference name="Telerik.Web.UI.Common.jQueryInclude.js" assembly="Telerik.Web.UI"/>
           <asp:ScriptReference name="MicrosoftAjax.js" assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
           <asp:ScriptReference name="MicrosoftAjaxWebForms.js" assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
           <asp:ScriptReference name="Telerik.Web.UI.Common.Core.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
           <asp:ScriptReference name="Telerik.Web.UI.Common.jQuery.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
           <asp:ScriptReference name="Telerik.Web.UI.Common.jQueryPlugins.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
           <asp:ScriptReference name="Telerik.Web.UI.Common.TouchScrollExtender.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
           <asp:ScriptReference name="Telerik.Web.UI.Common.Navigation.NavigationScripts.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
           <asp:ScriptReference name="Telerik.Web.UI.ComboBox.RadComboBoxScripts.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
           <asp:ScriptReference name="Telerik.Web.UI.Ajax.Ajax.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
           <asp:ScriptReference name="Telerik.Web.UI.Input.TextBox.RadInputScript.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
           <asp:ScriptReference Path="~/Scripts/jquery.jcarousel.min.js"  />
                   <asp:ScriptReference Path="~/Scripts/scripts_011612.js" />
       </Scripts>     
      </CompositeScript>
  </telerik:RadScriptManager>

When I look at the page in Firebug under scripts I see this:

1) ScriptResource.axd?d=.... 
the file starts with this:
var jQuery=window.jQuery=window.$=$telerik.$;
// Name: MicrosoftAjax.debug.js
// Assembly: System.Web.Extensions
// Version: 4.0.0.0
// FileVersion: 4.0.30319.237
//-----------------------------------------------------------------------
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------
// MicrosoftAjax.js
// Microsoft AJAX Framework.

2) ScriptResource.axd?d=...
This one contains my own javascript

3) Telerik.Web.UI.Webresource.axd?_TSM_Hidden....
Starts with:
/* START MicrosoftAjax.js */
//----------------------------------------------------------
// Copyright (C) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------
// MicrosoftAjax.js 

4)WebResource.axd?d=....
Starts with: 
function WebForm_PostBackOptions(eventTarget, eventArgument, validation, validationGroup, actionUrl, trackFocus, clientSubmit) {

My question once again is why doesn't it combine all the JavaScript into one single file such as scriptresource.axd. 

Am I doing something wrong?

5 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 30 Jan 2012, 11:02 AM
Hi Carl,

It is not a good idea to put Telerik and ASP.NET AJAX scripts in a CompositeScript and at the same time use RadScriptManager's combining functionality. This is because RSM does not read what is in the CompositeScript, so it adds the scripts required by RadControls again.

The best practice is to put in a CompositeScript only external scripts and leave the embedded ones in the Scripts collection of RadScriptManager. In this way you will get the minimum requests for those scripts - one for the CompositeScript and one for the combined Scripts collection.

Please let me know how it goes should you decided to reconfigure.

Greetings,
Simon
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Carl Sconnely
Top achievements
Rank 1
answered on 01 Feb 2012, 05:04 PM
Thank you for your reply, Simon

I have followed your suggestion:

Here is my Site1.Master:

<telerik:RadScriptManager ID="rsMan" runat="server"
       OutputCompression="Forced" EnableScriptCombine="true" ScriptMode="Auto">  
       <Scripts>
            <asp:ScriptReference name="Telerik.Web.UI.Common.jQueryInclude.js" assembly="Telerik.Web.UI"/>
            <asp:ScriptReference name="MicrosoftAjax.js" assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>  
            <asp:ScriptReference name="MicrosoftAjaxWebForms.js" assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            <asp:ScriptReference name="Telerik.Web.UI.Common.Core.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
            <asp:ScriptReference name="Telerik.Web.UI.Common.jQuery.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
            <asp:ScriptReference name="Telerik.Web.UI.Common.jQueryPlugins.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
            <asp:ScriptReference name="Telerik.Web.UI.Common.TouchScrollExtender.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
            <asp:ScriptReference name="Telerik.Web.UI.Common.Navigation.NavigationScripts.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
            <asp:ScriptReference name="Telerik.Web.UI.ComboBox.RadComboBoxScripts.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
            <asp:ScriptReference name="Telerik.Web.UI.Ajax.Ajax.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
            <asp:ScriptReference name="Telerik.Web.UI.Input.TextBox.RadInputScript.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>                                  
       </Scripts>
   
Now on the slave page, I have 
       
       
<asp:ScriptManagerProxy ID="ScriptManagerProxy2" runat="server">
            <CompositeScript ScriptMode="Auto">
                    <Scripts>
                        <asp:ScriptReference Path="/scripts/jquery.jcarousel.min.js" />       
                    </Scripts>
            </CompositeScript>
        </asp:ScriptManagerProxy>

Once again: when I launch the page, my browser makes 5 separate requests:

I have :

1) Default.aspx
2) ScriptResource.axd?d=1...
3) ScriptResource.axd?d=Ug2p..
4) Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=rsMan_Ts
5) WebResource.axd?d=hiJEgcjN...


I don't necessarily have a problem with the first 3 but i would assume the telerik system request would be combined into one call.

Am I doing something wrong?

My understanding of the concept was that when you put scritps into scriptmanager script or combineScript sections, the RSM combines, minifies, compresses ALL javascript into one single call.

 


0
Simon
Telerik team
answered on 03 Feb 2012, 08:20 PM
Hello Carl,

The one ScriptResource.axd request should be of the CompositeScript (this we cannot access, hence we cannot combine it). The Telerik.Web.UI.WebResource.axd is for all Telerik and Microsoft AJAX framework scripts, combined. The WebResource.axd requests is most probably for WebForms.js (this one we cannot access as well).

So, there should be three requests total. Could you please see the responses of each to confirm/refute the above and see what is the response of the second ScriptResource.axd?

Kind regards,
Simon
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Carl Sconnely
Top achievements
Rank 1
answered on 17 Feb 2012, 05:07 PM
Master pages has this:

<telerik:RadScriptManager ID="rsMan" runat="server"
       OutputCompression="Forced" EnableScriptCombine="true" ScriptMode="Auto">  
        <Scripts>
           <asp:ScriptReference name="Telerik.Web.UI.Common.jQueryInclude.js" assembly="Telerik.Web.UI"/>
           <asp:ScriptReference name="MicrosoftAjax.js" assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
           <asp:ScriptReference name="MicrosoftAjaxWebForms.js" assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
           <asp:ScriptReference name="Telerik.Web.UI.Common.Core.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
           <asp:ScriptReference name="Telerik.Web.UI.Common.jQuery.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
           <asp:ScriptReference name="Telerik.Web.UI.Common.jQueryPlugins.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
           <asp:ScriptReference name="Telerik.Web.UI.Common.TouchScrollExtender.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
           <asp:ScriptReference name="Telerik.Web.UI.Common.Navigation.NavigationScripts.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
           <asp:ScriptReference name="Telerik.Web.UI.ComboBox.RadComboBoxScripts.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
           <asp:ScriptReference name="Telerik.Web.UI.Ajax.Ajax.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
           <asp:ScriptReference name="Telerik.Web.UI.Input.TextBox.RadInputScript.js" assembly="Telerik.Web.UI, Version=2010.3.1317.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>                        
       </Scripts
       <CompositeScript>
        <Scripts>
            <asp:ScriptReference Path="/Scripts/scripts_011612.js" />
        </Scripts>                     
       </CompositeScript>
   </telerik:RadScriptManager>

default.aspx has 
<asp:ScriptManagerProxy ID="ScriptManagerProxy2" runat="server">
            <CompositeScript ScriptMode="Auto">
                    <Scripts>
                        <asp:ScriptReference Path="/scripts/jquery.jcarousel.min.js" />       
                    </Scripts>
            </CompositeScript>
        </asp:ScriptManagerProxy>

 Attached is the screenshot of my firebug script panel, 

I see 6 requests:

1) jquery one is requested from external source on purpose, thats fine
2) default.aspx  has javascript that is on the page, which should be combined into one call right?
3) scriptResource.axd - has request from <asp:ScriptReference Path="/Scripts/scripts_011612.js" /> 
4) scriptResource.axd - has request from <asp:ScriptReference Path="/scripts/jquery.jcarousel.min.js" />   not minified or compressed
5) Telerik.Web.UI 
6) WebResource.axd

So all those requests could not be combined into one simple call? 

If not, why is it doing three separate requests for 2nd default.aspx and   
 3rd scriptResource.axd and 4th scriptResource.axd ?
 
What am I doing wrong?
0
Simon
Telerik team
answered on 22 Feb 2012, 04:35 PM
Hello Carl,

The way I see it from your description and the provided code here is why each request exists:
  1. No comment.
  2. RadScriptManager works only with ScriptReference objects added to the control's Scripts collection. Scripts, defined in the page as <script> elements are outside of the responsibilities of the control (this holds true for ScriptManager as well).
  3. This is a CompositeScript, so it is not combined.
  4. This is also a CompositeScript and I am not sure why it does not get combined with the previous one. Perhaps, because it is defined in proxy, ScriptManager's base code handles each CS separately. You can test that if you replace RSM with SM.
  5. This is the combined script that RSM produces.
  6. This one is most probably the ASP.NET AJAX Framework WebForms.js file, which SM (and RSM) cannot access in any way, so it is always a separate request. This is built in the framework and we have tried to find a way to override the behavior and discovered that it was impossible - ASP.NET does not provide any way to override this behavior. It renders the script as a <script> element before anything else.
I hope this info helps you understand why are all those separate script requests.

Kind regards,
Simon
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ScriptManager and StyleSheetManager
Asked by
Carl Sconnely
Top achievements
Rank 1
Answers by
Simon
Telerik team
Carl Sconnely
Top achievements
Rank 1
Share this question
or