In this chapter you will learn how to incorporate jQuery into your web pages.
There are two ways to use jQuery:
To get started, first download a copy of jQuery and include it in your document.
There are two versions of jQuery available for downloading:
Both versions can be downloaded from: https://jquery.com/download/.
Always include the jQuery file before your custom scripts; otherwise, the jQuery APIs will not be available when your jQuery code attempts to access it.
If you don't want to download and host jQuery yourself, you can include it from a CDN (Content Delivery Network).
Both Google and Microsoft provides content deliver for the latest version.
To use jQuery from Google or Microsoft, use one of the following:
CDNs can offer a performance benefit by hosting jQuery on servers spread across the globe. This also offers an advantage that if the visitor to your webpage has already downloaded a copy of jQuery from the same CDN, it won't have to be re-downloaded.
Advantage of using the jQuery CDN:
Many users already have downloaded jQuery from Google or Microsoft when visiting another site. As a result, it will be loaded from cache when they visit your site, which leads to faster loading time. Also, most CDN's will make sure that once a user requests a file from it, it will be served from the server closest to them, which also leads to faster loading time.