To add jQuery to a Web Page
A developer has to follow some steps to add jQuery to a webpage and the basic steps are provided below:
- First the developer needs to download the jQuery library and the developer needs to do so from the jQuery.com.
- The developer needs to include jQuery from a CDN and one of the examples of the CDN is Google.
To download jQuery
The developer has an option to download one of the two versions of the jQuery.
- The developer can choose to download the production version of JQuery. This version is suitable for the developers who has a live website and the main reason behind that is it is minified and compressed.
- Another version is the development version and it is suitable for testing and development. The reason behind it being suitable for testing and development is that it is uncompressed and the codes are readable.
- The versions can be downloaded from jQuery.com.
- One hint: The downloaded file should be placed in the same directory as the pages where the developer needs that to use it.
One of its example is provided below: <head> <script src=”jquery-1.11.1.min.js”></script> </head>
If the developer chooses not to download and host the jQuery then the developer can a different thing and that is to include it from a CDN which stands for Content Delivery Network. The mighty Google and Microsoft have one thing in common and hat is they both host jQuery. The process to use jQuery from Google and Microsoft varies though.
<head> <script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js”></script> </head>
<head> <script src=”http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.1.min.js”></script> </head>