Book Image

ASP.NET jQuery Cookbook (Second Edition) - Second Edition

By : Sonal Merchant, Sonal Aneel Allana
Book Image

ASP.NET jQuery Cookbook (Second Edition) - Second Edition

By: Sonal Merchant, Sonal Aneel Allana

Overview of this book

jQuery is a lightweight JavaScript library that has changed the landscape of client scripting in web applications. Developed by John Resig in 2006, it has taken the web by storm because of its cross-browser compatibility and the ability to get more done with less code. It has gained popularity with ASP.NET developers and is now distributed with Visual Studio and the NuGet package manager. ASP.NET jQuery Cookbook explores the wide range of utilities that the jQuery library provides. It teaches you the nitty-gritty of plugging in these features in ASP.NET web applications. It covers every aspect of interfacing the library, right from downloading and including jQuery on web pages to selecting controls, handling events, and creating animations. This book also walks you through DOM traversal and manipulation in ASP.NET and then through visual effects and graphics in ASP.NET sites. It explores advanced features such as posting AJAX requests and writing plugins. It will provide you with all the information you need to use this library confidently with ASP.NET.
Table of Contents (15 chapters)
ASP.NET jQuery Cookbook Second Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Understanding CDN for jQuery


A Content Delivery Network (CDN) hosts content for users through large distributed systems. The advantage of using a CDN is to improve the performance. When using a CDN to retrieve the jQuery library, if the files have been downloaded earlier, they will not be re-downloaded. This can help you improve the response time.

How to do it…

The following CDNs are available for jQuery files:

  • jQuery's CDN provided by MaxCDN

  • The Google CDN

  • The Microsoft CDN

  • The CDNJS CDN

  • The jsDelivr CDN

To include jQuery on a web page, the URL of the respective CDN can be used so that files can be directly served from the CDN instead of using the local copies. The following table summarizes the respective CDN URLs for jQuery files:

CDN

URL

jQuery's CDN

Version 2.x:

http://code.jquery.com/jquery-2.x.x.js

http://code.jquery.com/jquery-2.x.x.min.js

Version 1.x:

http://code.jquery.com/jquery-1.x.x.js

http://code.jquery.com/jquery-1.x.x.min.js

The Google CDN

Version 2.x:

https://ajax.googleapis.com/ajax/libs/jquery/2.x.x/jquery.js

https://ajax.googleapis.com/ajax/libs/jquery/2.x.x/jquery.min.js

Version 1.x:

https://ajax.googleapis.com/ajax/libs/jquery/1.x.x/jquery.js

https://ajax.googleapis.com/ajax/libs/jquery/1.x.x/jquery.min.js

The Microsoft CDN

Version 2.x:

http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.x.x.js

http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.x.x.min.js

http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.x.x.min.map

Version 1.x:

http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.x.x.js

http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.x.x.min.js

http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.x.x.min.map

The CDNJS CDN

Version 2.x:

https://cdnjs.cloudflare.com/ajax/libs/jquery/2.x.x/jquery.js

https://cdnjs.cloudflare.com/ajax/libs/jquery/2.x.x/jquery.min.js

https://cdnjs.cloudflare.com/ajax/libs/jquery/2.x.x/jquery.min.map

Version 1.x:

https://cdnjs.cloudflare.com/ajax/libs/jquery/1.x.x/jquery.js

https://cdnjs.cloudflare.com/ajax/libs/jquery/1.x.x/jquery.min.js

https://cdnjs.cloudflare.com/ajax/libs/jquery/1.x.x/jquery.min.map

The jsDelivr CDN

Version 2.x:

https://cdn.jsdelivr.net/jquery/2.x.x/jquery.js

https://cdn.jsdelivr.net/jquery/2.x.x/jquery.min.js

https://cdn.jsdelivr.net/jquery/2.x.x/jquery.min.map

Version 1.x:

https://cdn.jsdelivr.net/jquery/1.x.x/jquery.js

https://cdn.jsdelivr.net/jquery/1.x.x/jquery.min.js

https://cdn.jsdelivr.net/jquery/1.x.x/jquery.min.map

Using CDNs for new releases

Note that CDNs may not have the latest files when new versions of the jQuery library are launched since it usually takes a couple of days for third-parties to update their files. In the case of new releases, always check the available version before downloading them.

How it works…

CDNs consist of servers situated in data centers in strategic locations across the globe. When a client requests a resource from a CDN, the server that is geographically closest to the client processes the request. These servers are also known as edge servers. In addition to this, edge servers have a caching mechanism to serve various assets. All this helps you improve the client's response time.

See also

The Using NuGet Package Manager to download jQuery recipe