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

Explain to me load times between CompositeScript and Scripts.

3 Answers 126 Views
ScriptManager and StyleSheetManager
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 2
Sean asked on 02 Sep 2011, 12:09 AM
Hi Telerik,

I am struggling with an unrelated issue, but was exploring my options, and noted something quirky. I wanted to try executing a function on document ready. As such, I did this:

            $(document).ready(function () {
                FixSplitter($find(rightPaneID));
            });

with my script declarations as such:

<telerik:RadScriptManager ID="ScriptManager1" Runat="Server" EnablePageMethods="True" >
    <CompositeScript>
        <Scripts>
            <asp:ScriptReference Path="~/Scripts/jquery-1.3.2.min.js" />
            <asp:ScriptReference Path="~/Scripts/jquery.json-2.2.min.js" />
            <asp:ScriptReference Path="~/Scripts/jquery-ui-1.7.2.custom.min.js" />
            <asp:ScriptReference Path="~/Scripts/Dashboard/Dashboard.js" />
            <asp:ScriptReference Path="~/Scripts/jquery.cookies.min.js" />
            <asp:ScriptReference Path="~/Scripts/jquery.hotkeys-0.7.9.js" />
            <asp:ScriptReference Path="~/Scripts/jquery.updnWatermark.js" />
            <asp:ScriptReference Path="~/Scripts/Master.js" />
        </Scripts>
    </CompositeScript>
    <Scripts>
        <asp:ScriptReference Name="Telerik.Web.UI.Common.Core.js" Assembly="Telerik.Web.UI"  />
    </Scripts>
</telerik:RadScriptManager>

I would like to keep my scripts combined. They should be combined. Loading scripts not combined is inefficient. Yet, when I have my jQuery scripts declared inside of CompositeScripts I am told 

Uncaught TypeError: Property '$' of object [object DOMWindow] is not a function

If I move all my script declarations such that the declaration is like this:

<telerik:RadScriptManager ID="ScriptManager1" Runat="Server" EnablePageMethods="True" >
    <CompositeScript>
        <Scripts>
        </Scripts>
    </CompositeScript>
    <Scripts>
        <asp:ScriptReference Path="~/Scripts/jquery-1.3.2.min.js" />
        <asp:ScriptReference Path="~/Scripts/jquery.json-2.2.min.js" />
        <asp:ScriptReference Path="~/Scripts/jquery-ui-1.7.2.custom.min.js" />
        <asp:ScriptReference Path="~/Scripts/Dashboard/Dashboard.js" />
        <asp:ScriptReference Path="~/Scripts/jquery.cookies.min.js" />
        <asp:ScriptReference Path="~/Scripts/jquery.hotkeys-0.7.9.js" />
        <asp:ScriptReference Path="~/Scripts/jquery.updnWatermark.js" />
        <asp:ScriptReference Path="~/Scripts/Master.js" />
        <asp:ScriptReference Name="Telerik.Web.UI.Common.Core.js" Assembly="Telerik.Web.UI"  />
    </Scripts>
</telerik:RadScriptManager>

Presto! The error disappears. 

Is there a good way to avoid this...? Could I have an explanation of what's going on so that I may fully understand the problem?

Thanks.

3 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 13 Sep 2011, 02:32 PM
Hi Sean,

ScriptManager's CompositeScript is always output first, before the rest of the scripts referenced in the control. However, RadScriptManager seems to have a problem with that and it places the CompositeScript last. So, in your case, both setups should yield the same results - currently they do with SM and not with RSM.

We will investigate further why RSM behaves in this way and will fix it as it's the default SM behavior. I updated your Telerik points for pointing us to the issue.

Greetings,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Sean
Top achievements
Rank 2
answered on 23 Sep 2011, 09:09 PM
Hi Simon,

Thanks for looking into this. Very interesting! I'll play around with it a bit more until I'm happy with the results. :)

On another note, I didn't actually see any change to my Telerik points. I wasn't expecting anything when posting my original thread, so I'm not being pushy or anything, just thought a ball may have been unintentionally dropped.

Sean
0
Accepted
Simon
Telerik team
answered on 27 Sep 2011, 10:58 AM
Hello Sean,

Your points were well deserved and this was a mistake on my side. Everything should be fine now.

Please excuse me for my omission.

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
Sean
Top achievements
Rank 2
Answers by
Simon
Telerik team
Sean
Top achievements
Rank 2
Share this question
or