Why does EnableScriptCombine=true cause jQuery to be loaded twice?

5 posts, 0 answers
  1. Rob
    Rob avatar
    43 posts
    Member since:
    Aug 2010

    Posted 17 Aug 2012 Link to this post

    If I include jQuery in a RadScriptManager like this (ignore the fact that I'm loading a different version, that just makes the problem easier to spot):

    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnableScriptCombine="true">
    <CompositeScript>
    <Scripts>
        <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
        <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" Path="~/SCRIPTs/jquery-1.8.0.min.js" />
    </Scripts>
    </CompositeScript>
    </telerik:RadScriptManager>

    And then add a Telerik control to the page:

    <telerik:RadDateTimePicker ID="RadDateTimePicker1" runat="server">
    </telerik:RadDateTimePicker>

    Then if you search among the files loaded (I used search in the Firebug script tab with the multiple files option ticked - search for 'jquery.org') then you'll see that there are two copies of jQuery loaded - the 1.8.0 one in a ScriptResource.axd file and the 1.7.2 one in a Telerik.Web.UI.WebResource.axd file.

    If you turn script combining off then only one version of jQuery is loaded, the 1.8.0 one, however you then of course see about 12 separate script requests.

    I'd like to use script combining, but I'd like to only load jquery once, how can I do this?
  2. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 22 Aug 2012 Link to this post

    Hi Rob,

    In case you want to disable the build-in jQuery and use some other version, the newly introduced EnableEmbeddedjQuery property of the RadScriptManager should be used. Here is a help article on the matter.

    Kind regards,
    Dimitar Terziev
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Rob
    Rob avatar
    43 posts
    Member since:
    Aug 2010

    Posted 22 Aug 2012 Link to this post

    Thanks for your comment, however it doesn't answer my question.  As I said in my post, ignore the fact that I'm loading a different version, it makes no difference to the problem it just makes spotting the problem more obvious.

    Rob
  5. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 28 Aug 2012 Link to this post

    Hello Rob,

    Regarding your question, I have no clear answer since I was unable to reproduce this behavior locally. As for the implementation used, I have noticed that the JQuery is referenced through our assembly. Such type of referencing is used when the referenced script is embedded in the assembly through which it has been referenced. The general approach in such scenarios is to reference the script only by path or from an assembly where it's embedded. I have prepared a sample project where the build-in JQuery is disabled thus using external script, and the build-in JQuery is not being loaded. In case the build-in JQuery is not disabled there will be two JQuery scripts loaded, the build-in one and the additionally referenced.

    Kind regards,
    Dimitar Terziev
    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.
  6. Rob
    Rob avatar
    43 posts
    Member since:
    Aug 2010

    Posted 28 Aug 2012 Link to this post

    Thanks for your response.  I have indeed disabled the embedded jQuery in our production code, though you should be aware there is currently an issue with the disabling of jQuery and the RadGrid with scrolling enabled.  I have logged a support ticket about that and it is being progressed.

    Rob
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017