Wednesday, June 26, 2013

Introduction to JQuery

JQuery is nothing but a modified version of Java Scripts. JQuery is easier to learn and to implement. It is a JavaScript Library. Before learning JQuery, you need to know three things.

  • HTML
  • CSS
  • Java Script
And Remember another thing, you are just writing the Java Script in another way.


Introduction:

jQuery is a lightweight Java Script Library. Instead of writing number of lines of code in Java Script, we can write here single line of code to perform the same task or even more. This happens because, jQuery takes lots of commonly performed tasks into a single function and gives that function call to us. Not only Java Scripts, it also simplifies AJAX calls and also DOM manipulation.

JQuery is the most popular Java Script Frame work than many others. It is also used by some big companies like 
  • Google
  • Microsoft
  • IBM
JQuery runs almost similarly in all kinds of browsers.

How to Use JQuery?

Inorder to use the JQuery, you need to either
  • Download the jQuery library from the jQuery.com
  • Include jQuery from a CDN, like Google.
CDN means Content Delivery Network.

If you want to download the jQuery library, there are two versions available.
  • Production Version - Used for live websites and it is compressed.
  • Development Version - Used for testing and it is uncompressed or readable.
To include the jQuery in our page, we need to include <script> tag in the head section and specify the source to be the path of the jquery library.

<head>
<script src="jquery-1.10.1.min.js"></script>
</head>
You can observe that we have not used type="text/javascript" in the above code. This is because, type is javascript by default in HTML5.

If you are using any CDN, then you can directly link the script to the location by using
src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"
To get the latest version of the jQuery library, we can remove the last number or the last two numbers in the path, then Google automatically returns the current version of the JQuery. Also Microsoft hosts JQuery and the path of the Microsoft Jquery is
src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.10.1.min.js"
 The advantage we have in using the CDNs is because of the fast accessing. As most of the users already visits another site with JQuery, the jQuery files will be downloaded or kept at a server near to them. Hence when a user access your web page, it gets the JQuery from the Cache and loads the page faster.