Adding jQuery to Your Web Page or Entire Website

You can add jQuery to your HTML website by specifying it within the “src” attribute of an <SCRIPT> tag. <SCRIPT> tags are usually placed inside the <HEAD> section of each web page where you need jQuery to be added:

<script src="jquery-1.7.1.min.js" type="text/javascript"></script>

You probably want to add the minified (min) version of the library to your web page, unless you are also interested in looking at internal jQuery library code.

The location of the script is up to the programmer. If the jQuery library file was added to the same directory where your HTML file is located, then all you have to do is supply the file name as shown in the example above.

How to Add jQuery From a Remote URL

If you don’t want to host jQuery on your server, you can add it directly from another place, for example, from Google Hosted Libraries(link), which is a site that hosts a various number of all kinds of JavaScript libraries:

<script src="//"></script>

Notice the http protocol is missing in this link. This is done on purpose. The protocol “HTTP” or “HTTPS” will be automatically chosen based on the protocol of the web page you are adding this script to.

The Difference Between “Minified” (min) And Standard Versions

In the first example the filename used was jquery-1.7.1.min.js. Notice “min” in the file name. This means that the JavaScript code in this file is minified (compressed) to save space. Aminified file is smaller and therefore is quicker to download. This is done at expense of readability of the code. Often a minified JavaScript script replaces names of all redundant JavaScript functions and variable names to save space. A minified script removes all code formatting, comments, as well as tabs and space characters, which makes the code unreadable by a programmer.

Minified versions of jQuery (or other JavaScript libraries) are usually used to decrease the time which takes to load your web page. The space reduction decreases the number of bytes the browser needs to download in order to begin making calls to main jQuery methods.

A non-minified version of jQuery library can be used when you are still developing your website locally on your computer and sometimes need to look at how jQuery library works internally. The standard version of the jQuery library

jQuery Tutorials