Objectives and outcomes

In this tutorial we are going to learn how to setup jquery environment on localhost or using CDN (content delivery network).

Jquery environment on localhost

You can download jquery package from https://jquery/download then link either jquery-x.x.x.js or jquery.min.js to your web page by providing the correct path. For example :-

<head>
<script src="jquery/jquery.min.js"></script>
</head>


Jquery environment using CDN

You can also link jquery script by providing CDN link in head section of the webpage.


<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
</head>


Executing the javascript

We can run the javascript with jquery in two ways: First is by writing the script in same document and the other is by linking an external file. For example :


first method
<head>
<script src="jquery/jquery.min.js"></script>
</head>
<body>
<script>
.
.
.
</script>
</body>


Second method
<head>
<script src="jquery/jquery.min.js"></script>
<script src="external.js"></script>
</head>
<body>
</body>

external.js file
$document.ready({
...
});


Jquery is the javascript framework which helps the purpose of write less and perform more actions. Jquery actions and statements are mostly written inside $(document).ready({}) function so that events can occur as soon as the document is ready.