www.pickatutorial.com Computer Tutorials
Top eBooks: C/C++ | C# | Android | Mathematics | Database | Cloud | Graphics | Networking | Oracle | Hardware | AI
Top Tutorials: C/C++ | C#.NET | PHP MySQL | Java | Java Script | jQuery | HTML | xHTML | HTML5 | VB Script| CSS
Lessons Adding jQuery to a Web Page Bookmark and Share
Tutorial Home
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Lesson 9
Lesson 10
Lesson 11
Lesson 12
Lesson 13
Lesson 14
Lesson 15
Lesson 16
Lesson 17
Lesson 18
Lesson 19
Lesson 20
Lesson 21
Lesson 22
Lesson 23
Lesson 24
Lesson 25
Lesson 26
Lesson 27

To use jQuery, we first need to include it on the pages where we wish use its functionality.

Fortunately jQuery is not a huge collection of files. It is just a single file having a size in Kbs. We can download it from its official website http://www.jquery.com.

The jquery website offers a choice between a "Production" version and a "Development" version. The production version has been compressed for our live websites. As it has been compressed, it takes least amount of space that is particularly important for the visitors as it has to be downloaded to their machines along with the rest of the content. On the other hand the "Development" version is well suited for testing and development purposes. It has not been minified or compressed, so that when we run into an error, we can actually see where in jQuery it happens.

Once downloaded, we need to reference the jQuery JavaScript file on our pages, using the <script> HTML tag as under:

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

For live websites there is another relatively better way to include the jQuery script file. Instead of downloading and hosting jQuery ourselves we can include it from a CDN (Content Delivery Network). Both Google and Microsoft host several different versions of jQuery and other JavaScript frameworks. It not only saves us from having to download and store the jQuery library, it has another advantage too. In case of CDN, as the file comes from a common URL that other websites may also use as well, chances are that when a visitor reaches our website and his browser requests the jQuery file, it may already be in its cache, thus speeding up the loading of our website.

Using jQuery from a CDN is as easy as the downloaded version, only the URL changes. The following code references the jQuery file from the google CDN:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"> </script>

Next >>> Lesson No. 3: First jQuery Code

Home - Advertise - Contact - Disclaimer - About Us
© Since 2006 pickatutorial.com -- All Rights Reserved.