Microsoft Ajax Content Delivery Network - jQuery

Microsoft Ajax Content Delivery Network - jQuery


The Microsoft Ajax Content Delivery Network (CDN) enables you to easily add popular JavaScript libraries such as 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. 


By taking advantage of the Microsoft Ajax CDN, you can significantly improve the performance of your Ajax applications. The contents of the Microsoft Ajax CDN are cached on servers located around the world. In addition, the Microsoft Ajax CDN enables browsers to reuse cached JavaScript files for Web sites that are located in different domains. 


The Microsoft Ajax Content Delivery Network supports SSL (HTTPS) in case you need to serve a web page using the Secure Sockets Layer.


The Microsoft Ajax CDN includes the following libraries which have been uploaded by community members:

  • jQuery (owned by the jQuery Team — www.jQuery.com)
  • jQuery UI (owned by the jQuery UI Team — www.jQueryUI.com)
  • jQuery Validation (owned by the jQuery team – www.jQuery.com)
  • jQuery Cycle
  • Ajax Control Toolkit (owned by the CodePlex Foundation – www.codeplex.org)

The Microsoft Ajax CDN also includes the following libraries which have been uploaded by Microsoft:

  • ASP.NET Ajax
  • ASP.NET MVC JavaScript Files 

Microsoft does not claim ownership of any third-party libraries hosted on this CDN. To the extent that you are making use of such third-party libraries as hosted on this CDN, such transaction is between you and the respective owners of those libraries. Microsoft provides no additional intellectual property rights including no implied patent rights for any third party libraries hosted on this CDN.

If you wish to submit your JavaScript library, and your library is one of the top 5 JavaScript libraries (as listed on http://trends.builtwith.com) or extensions/plugins to these libraries that are (a) popular; or (b) helpful for use on ASP.NET then please contact AjaxCDNSubmission@Microsoft.com.

ajax.microsoft.com renamed to ajax.aspnetcdn.com

The CDN used to use the microsoft.com domain name and has been changed to use the aspnetcdn.com domain name. This change was made to increase performance because when a browser referenced the microsoft.com domain it would send any cookies from that domain across the wire with each request. By renaming to a domain name other than microsoft.com performance can be increased by as much to 25%. Note ajax.microsoft.com will continue to function but ajax.aspnetcdn.com is recommended.

  • Old Format: http://ajax.microsoft.com/ajax/jQuery/jquery-1.5.1.js
  • New Format: http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.1.js

Visual Studio 2008 .vsdoc Support

To use the .vsdoc files properly with Visual Studio 2008 you need to make sure that you have VS 2008 SP1 installed and the hotfix for vsdoc files installed. You can get these from here:

Download Visual Studio 2008 SP1

Download .vsdoc hotfix for Visual Studio 2008 SP1

Using ASP.NET Ajax from the CDN

When using ASP.NET 4, you can redirect all requests for ASP.NET framework scripts to the CDN. Retrieving scripts from the CDN instead of your local web server can substantially improve the performance of public ASP.NET websites.

Use the ScriptManager EnableCDN property to redirect all ASP.NET framework script requests to the Microsoft Ajax CDN:

  1. <asp:ScriptManager  
  2.   ID="ScriptManager1"  
  3.   EnableCdn="true"  
  4.   Runat="Server" />  

Using jQuery from the CDN

You can use jQuery scripts from the CDN in your Web application by adding the following script element to a page:

<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.5.1.js" type="text/javascript"></script>                        

The CDN also includes the minified version of the jQuery script, which you can get using the following element:


<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.5.1.min.js" type="text/javascript"></script>

The following sample page uses the CDN version of the jQuery library to display the contents of a div element when a button is clicked.

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  2. <html xmlns="http://www.w3.org/1999/xhtml">  
  3. <head>  
  4.     <title>jQuery from Microsoft AJAX CDN</title>  
  5.     <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.5.js" type="text/javascript"></script>  
  6.   
  7.     <script type="text/javascript">  
  8.       
  9.     $( domReady );  
  10.       
  11.     function domReady() {  
  12.         $('#btn').click( showMessage );  
  13.     }  
  14.       
  15.     function showMessage() {  
  16.         $('#message').fadeIn('slow');  
  17.     }  
  18.       
  19.     </script>  
  20. </head>  
  21. <body>  
  22.   
  23. <button id="btn">Show Message</button>  
  24.   
  25. <div id="message" style="display:none">  
  26.   
  27.     <h1>Hello from jQuery!</h1>  
  28.   
  29. </div>  
  30.   
  31. </body>  
  32. </html>  
You can learn more about jQuery and download a local copy of jQuery by visiting the jQuery Web site.

Using jQuery UI from the CDN

The Microsoft Ajax CDN also includes the jQuery UI library. The jQuery UI library includes a rich set of widgets and effects that you can use in your ASP.NET applications. For example, the following page illustrates how you can use the jQuery UI Datepicker in the context of an ASP.NET Web Forms application to display a pop-up calendar:

  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="TestjQueryUICDN.WebForm1" %>  
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  3. <html xmlns="http://www.w3.org/1999/xhtml">  
  4. <head runat="server">  
  5.     <title>Using jQuery UI from the CDN</title>  
  6.     <link type="text/css" rel="Stylesheet" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/themes/redmond/jquery-ui.css" />  
  7. </head>  
  8. <body>  
  9.     <form id="form1" runat="server">  
  10.     <div>  
  11.       
  12.         <asp:TextBox ID="txtStartDate" ClientIDMode="Static" runat="server" />  
  13.   
  14.     </div>  
  15.     </form>  
  16.   
  17.     <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.5.js"></script>  
  18.     <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/jquery-ui.js"></script>  
  19.   
  20.     <script type="text/javascript">  
  21.   
  22.         $("#txtStartDate").datepicker();  
  23.   
  24.     </script>  
  25. </body>  
  26. </html>  

When you move focus to the TextBox using your keyboard, a calendar is displayed:

Popup calendar created with Datepicker

Notice that you must include three files from the CDN in the code above:

  • The jQuery library — The jQuery UI library depends on the jQuery library. You must add the jQuery library to your page before you add the jQuery UI library.

  • The jQuery UI library — The jQuery UI library contains all of the jQuery UI effects and widgets such as the Datepicker widget used in the page above. 

  • A jQuery UI theme — The jQuery UI supports different themes. The page above includes a link to a CSS file to import the Redmond theme.

All of the standard jQuery UI themes are included on the Microsoft CDN. Visit this page to view thumbnails for each theme.

To learn more about the jQuery UI library, visit the official jQuery UI website.



Third-Party Files on the CDN

These libraries are provided by the respective vendors and not Microsoft.

jQuery Releases on the CDN

The following releases of jQuery are hosted on the CDN:

jQuery version 1.5.1

  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.1.js
  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.1.min.js 

jQuery version 1.5

  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.js
  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.min.js
  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5-vsdoc.js 

jQuery version 1.4.4

  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.4.js
  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.4.min.js
  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.4-vsdoc.js

jQuery version 1.4.3

  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.3.js
  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.3.min.js
  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.3-vsdoc.js

jQuery version 1.4.2

  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.2.js
  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.2.min.js
  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.2-vsdoc.js

jQuery version 1.4.1

  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.1.js
  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.1.min.js
  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.1-vsdoc.js 

jQuery version 1.4

  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.js
  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.min.js 

jQuery version 1.3.2

  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.3.2.js
  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.3.2.min.js
  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.3.2-vsdoc.js
  • http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.3.2.min-vsdoc.js 



jQuery UI Releases on the CDN

The following releases of the jQuery UI library are hosted on this CDN. Click each link to see the actual list of files.


jQuery Validation Releases on the CDN

The following releases of the jQuery Validation library are hosted on this CDN. Click each link to see the actual list of files.


jQuery Templates Releases on the CDN

The following releases of the jQuery Templates plugin are hosted on this CDN. Click each link to see the actual list of files.


jQuery Cycle Releases on the CDN

The following releases of the jQuery Cycle plugin are hosted on this CDN. Click each link to see the actual list of files.




Ajax Control Toolkit Releases on the CDN

The following releases of the client portion of the Ajax Control Toolkit are hosted on this CDN. Click the link to see the actual list of files.


Microsoft Files on the CDN

These libraries were uploaded by Microsoft.

ASP.NET Ajax Releases on the CDN

The following releases of the ASP.NET Ajax Library are hosted on the CDN. Click each link to see the actual list of files.

ASP.NET MVC Releases on the CDN

The following ASP.NET MVC JavaScript files are hosted on this CDN:

ASP.NET MVC 1.0

  • http://ajax.aspnetcdn.com/ajax/mvc/1.0/MicrosoftMvcAjax.js
  • http://ajax.aspnetcdn.com/ajax/mvc/1.0/MicrosoftMvcAjax.debug.js 

ASP.NET MVC 2.0

  • http://ajax.aspnetcdn.com/ajax/mvc/2.0/MicrosoftMvcAjax.js
  • http://ajax.aspnetcdn.com/ajax/mvc/2.0/MicrosoftMvcAjax.debug.js 

ASP.NET MVC 3.0

  • http://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.unobtrusive-ajax.js
  • http://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.unobtrusive-ajax.min.js
  • http://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.validate.unobtrusive.js
  • http://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.validate.unobtrusive.min.js

For information about the terms of use for the CDN, see Microsoft Ajax CDN Terms of Use.

Nhận xét

Bài đăng phổ biến từ blog này

Công ty chứng khoán đón đầu cơ hội (dau tu cong nghe)

The Redback