As mentioned in my previous post, rather then hosting jQuery libraries on our sever we can directly use them from CDN services available from Microsoft & Google. And there are various advantages of using this. In this article we will see on how to use jQuery library hosted at Microsoft Ajax Content Delivery Network(ajax.aspnetcdn.com)
Microsoft Ajax CDN includes jQuery ,jQuery UI, jQuery Validation, jQuery Cycle, Ajax Control Toolkit, ASP.NET Ajax, ASP.NET MVC JavaScript Files. For detail list of files available and versions supported please visit this link.
The Microsoft Ajax Content Delivery Network (CDN) enables you to easily add jQuery to your Web applications. For example, you can start using jQuery simply by adding a <script> tag to your page that points to ajax.aspnetcdn.com.
Using jQuery from the CDN
<script
src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.4.js"
type="text/javascript">
</script>
Minified version:
<script
src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.4.min.js"
type="text/javascript">
</script>
VSDoc Version:
<script
src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.4-vsdoc.js"
type="text/javascript">
</script>
Using jQuery UI from the CDN
<script
src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.6/jquery-ui.js"
type="text/javascript">
</script>
Using jQuery UI Themes from the CDN
To access jQueryUI themes, along with jquery.js and jquery-ui.js you also need to add reference the corresponding .css file. All of the standard jQuery UI themes are hosted on this CDN
<link type="text/css" rel="Stylesheet"
href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.6/themes/redmond/jquery-ui.css" />
Note: You don't need to host the .css file and the associated images on your server, everything is accessed from the CDN service. Wow… that's gr8.
Versions Supported:
jQuery: 1.4.4, 1.4.3, 1.4.2, 1.4.1, 1.4
jQuery UI: 1.8.6, 1.8.5
Themes: All of the standard jQuery UI themes under version 1.8.5 and 1.8.6 are hosted on this CDN
Complete Example:
<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><title>Using jQuery UI from the CDN</title><script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.4.js"></script><script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.6/jquery-ui.js"></script><link type="text/css" rel="Stylesheet" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.6/themes/redmond/jquery-ui.css" /></head><body><form id="form1" runat="server"><div><asp:TextBox ID="txtStartDate" ClientIDMode="Static" runat="server" /></div></form><script type="text/javascript">$("#txtStartDate").datepicker();</script></body></html>
Related Links
- Using CDN hosted jQuery Library
- Using jQuery Scripts hosted @ Google
- Microsoft Ajax Content Delivery Network
0 comments
Posts a comment