Link to home
Start Free TrialLog in
Avatar of Craig Beamson
Craig BeamsonFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Using AjaxToolkit (AjaxFrameworkMode="Explicit") to limit unneccessary JS files

I had a previous post on Experts Exchange, asking more generally about optimising the output of the AjaxToolkit.  The solution offered was very helpful and pointed me to: http://lancezhang.wordpress.com/2008/11/15/aspnet-ajax-performance/
This walkthrough appears to cover compression and combination of JS files but does not appear to do anything related to excluding unneeded AJAX modules.

Specifically, I just want to have a page with one textbox, one button and an AJAX AutoComplete extender - but have a minimal download size to suit browsers with slow download speeds.  My current implemention works but has the downside of downloading BarChart / CascadingDropDown / ColorPicker, either as distinct JS files, or as one combined file with a similar overall filesize (about 200KB)

The AjaxFrameworkMode="Explicit" condition appeared to be what I wanted to limit which parts fo the AJAX library are downloaded to the client, but a few tests don't show it having any limiting factor.  Before using it, my client was downloading 82 scripts, after using it, still 82!

My current stage of experimentation is as below.  Analysing what my browser is downloading with Fiddler shows it is requesting all 82 JS files.

I'm using the .net 4.0 framework with the AjaxControlToolkit version 4.1.7.725.
Any idea what I can do to force the page to ONLY download the parts of the toolkit that are needed?

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="skeleton_Default" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="act" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
	<title>Test</title>
</head>
<body>
	<form id="form1" runat="server">
		<ajaxToolkit:ToolkitScriptManager ID="AjaxScriptmanager" AjaxFrameworkMode="Explicit" runat="server" CombineScripts="false" ScriptMode="Release" LoadScriptsBeforeUI="false" EnablePartialRendering="false">
			<Scripts>
				<asp:ScriptReference Name="MicrosoftAjax.js" />
				<asp:ScriptReference Name="AutoComplete.AutoCompleteBehavior.js" Assembly="AjaxControlToolkit, Version=4.1.7.725, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />
			</Scripts>
		</ajaxToolkit:ToolkitScriptManager>
		<div>
			<asp:TextBox ID="SearchBox" runat="server" />
			<asp:Button ID="SearchButton" Text="Search" runat="server" />
			<act:AutoCompleteExtender ID="tbSearchAutocompleteExtender" runat="server" TargetControlID="SearchBox" ClientIDMode="Static"
				ServicePath="AutoComplete.asmx" ServiceMethod="GetCompletionList" MinimumPrefixLength="1"
				CompletionInterval="1" CompletionSetCount="10"
				FirstRowSelected="false">
			</act:AutoCompleteExtender>
		</div>
	</form>
</body>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of guru_sami
guru_sami
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Craig Beamson

ASKER

Turns out that the version I'm using IS the latest version but what I needed was a pointer towards the Control Bundles area.  Unless you already know it exists, its not easy to find!