Ajax Control Toolkit is loading too many script resources
Asked Answered
A

1

9

I created a new project. I installed Ajax Control Toolkit from NuGet. Then I created a new page aspx with following code:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <ajaxToolkit:ToolkitScriptManager ID="toolkitScriptMaster" runat="server">
        </ajaxToolkit:ToolkitScriptManager>
       hello!!!!

    </div>
    </form>
</body>
</html>

I was dumbfounded when I saw that ajaxtookit created 152 scriptresources files. I am worried because I know that this can affect the loading time of the page.

Is it normal?

What can I do?

Aeromechanics answered 31/10, 2013 at 15:34 Comment(3)
Find jQuery/JavaScript alternatives to the functionality you need. Microsoft has abandoned the toolkit and it currently is maintained as an open source project.Scanty
I use a mixture of the ajaxControlToolkit and jQuery and I know that it is not normal for 150 scriptresource files to be installed. Where are these files being installed at?Allegiance
I have the same problem happening on a .net 3.5 website. The resources are 150 calls to scriptresource.axd for various javascript resources. Why aren't those all in one script? These many calls cannot be good for the server.Cytoplasm
P
17

CodePlex's AjaxControlToolkit release of July 2013 introducing control bundles.

After this by default AjaxControlToolkit loads all scripts. So, to manage what scripts for what controls should be added and grouped you need to add AjaxControlToolkit.config to root of your web application project. Like in the following example:

<ajaxControlToolkit>
  <controlBundles>
    <controlBundle>
      <control name="CalendarExtender" />
      <control name="ComboBox" />
        </controlBundle>
    <controlBundle name="CalendarBundle">
      <control name="CalendarExtender"></control>
    </controlBundle>
  </controlBundles>
</ajaxControlToolkit>

Then you will need to specify which bundels are going to be used on which page (or master page if you have controls which are used on all pages) by adding bundle with specific name to toolkit script manager control:

<ajaxToolkit:ToolkitScriptManager runat="server" CombineScripts="true" 
  ScriptMode="Release" >
  <ControlBundles>
       <ajaxToolkit:ControlBundle Name="Calendar" />
  </ControlBundles>
</ajaxToolkit:ToolkitScriptManager>

Remarks: here you can find example of the config which contains most (maybe all definition of the controls from ajax control toolkit library).

Preuss answered 22/11, 2013 at 23:32 Comment(1)
Finally someone answered my question. Thanks!Aeromechanics

© 2022 - 2024 — McMap. All rights reserved.