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

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

4 Answers 283 Views
ScriptManager and StyleSheetManager
This is a migrated thread and some comments may be shown as answers.
Dev
Top achievements
Rank 1
Dev asked on 17 Aug 2012, 11:55 AM
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?

4 Answers, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 22 Aug 2012, 07:26 AM
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.
0
Dev
Top achievements
Rank 1
answered on 22 Aug 2012, 10:00 AM
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
0
Dimitar Terziev
Telerik team
answered on 28 Aug 2012, 08:04 AM
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.
0
Dev
Top achievements
Rank 1
answered on 28 Aug 2012, 10:22 AM
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
Tags
ScriptManager and StyleSheetManager
Asked by
Dev
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Dev
Top achievements
Rank 1
Share this question
or