TWO WAY TO EMBED JQUERY LIBRARY IN YOUR WEBPAGE :
1. Using a local file
2. Using the Content Delivery Network (CDN)
WAY ONE: Using a local file:
The jQuery library can be downloaded from http://jquery.com/download/. At the time of this writing, the latest version of jQuery was 2.1.0. Download the compressed (production) version of the library if you don’t intend to modify or debug the jQuery JavaScript code. Otherwise, you can download the uncompressed (development) version.If your user base is still using Internet Explorer 8 or older, download the latest version of jQuery 1.x. You should download the latest version of jQuery 2.x if your user base is using Internet Explorer 9 (or newer) or any other new version of browsers such as Firefox, Google Chrome, and Apple Safari
<script src="jquery.min.js"></script>
Tip: Place the downloaded file in the same directory as the pages where you wish to use it.Note
WAY TWO: Using the Content Delivery Network (CDN)
CDN is a distributed network of servers that hosts open source libraries like jQuery. When a request is made in a browser to access the jQuery library, CDN identifies the closest server and provides the jQuery JavaScript file to the browser
The advantages of using CDN include:
If another application
has already used the CDN to locate the jQuery JavaScript file, the –
chances are the file is in the browser’s cache. If it is in the cache,
that copy of the library will be used; otherwise it will be downloaded
from the closest server.
– Has a faster download since the closest server is used to deliver the file.
The disadvantage of using CDN include:
The
only problem with using CDN is that if an Internet connection is not
available, the web page won’t work. This is an issue for developers who
sometimes want to develop and test their sites offline.
There are many CDN provider . you can use any one of them .
SYNTAX:
<script src="address"></script>
Some of the website that provide cdn are
EXAMPLE:using jquery.com
<script src="http://code.jquery.com/jquery-1.12.0.min.js"></script>
No comments:
Post a Comment