The Web Toolkit supports loading up jQuery in a variety of ways. jQuery.js is provided as a WebResource and by default is automatically loaded from there by controls. However you can individually overrride the location from which jQuery is loaded at the Page or control level.
Globally you can use the following static/constant variables to configure the default jQuery load location:
ControlResources.LoadMode and ControlResources.jQueryCdnUrl
Deteremines where jQuery is loaded from by default. It defaults to jQueryLoadModes.WebResource, but can be ContentDeliveryNetwork or Script or None. If none is used only explict URLs passed are rendered.
You can configure these values once on Application_Start or other entry point for the application:
// Force jQuery to be loaded off Google Content Network
ControlResources.jQueryLoadMode = JQueryLoadModes.ContentDeliveryNetwork;
ControlResources.jQueryCdnUrl = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js";
jQueryCdnUrl defaults to the latest version of the Google API (actually same as shown above) so typically this value doesn't need to be set. The generated HTML generates into the header (if
tag exists - otherwise into HTML body) and provides fallback to WebResources if the CDN url is unavailable:
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"
type="text/javascript"></script>
<script type="text/javascript">
if (typeof(jQuery) == 'undefined')
document.write(unescape("%3Cscript src='/WestWindWebToolkitWeb/wwSC.axd?r=Westwind.Web.Controls.Resources.jquery.js' type='text/javascript'%3E%3C/script%3E"));
</script>
which allows loading even when no internet connection to the CDN is available.
The jQueryCdnUrl can also be specified as a local Web Url using root relative syntax:
ControlResources.jQueryCdnUrl = "~/scripts/jquery.min.js";
The same rules apply for jQuery.ui.js library.
Control Overrides
Most of the jQuery based controls allow overriding of the jQueryUrl to specify an explicit path root relative or absolute path jQuery. jQueryUrl can be one of these values:
- WebResource
- Any root relative or fully qualified URL
- An empty string
The latter causes the control not to emit a jQuery reference at all.
© West Wind Technologies, 1996-2016 • Updated: 12/19/15
Comment or report problem with topic