What is JQuery?

What is JQuery?

JQuery is a javascript library. It has additional methods and ways to simplify javascript programming.

Followings are some of the advantages for jquery:

  • easy to learn
  • simple syntax
  • large open source library
  • ajax support
  • lots of jquery plugins are available to use
  • great documentation

Why should I use JQuery?

Jquery provides better way to interect with dom elements, it is easy to create animations, widgets and dynamic web segments using ajax.

Without reinventing a wheel you have access to a library which is maintained by many developers you get the best. Using jquery you can perform following different operations:

  • easy to interect with form elements
  • easy to modify and play with html elements
  • easy to create async calls using ajax
  • easy to create animations
  • easy to make changes to css property of an element
  • easy to create plugins, form validation etc..

How do I install JQuery?

JQuery basically comes with single javascript file that you can include in your html code. Once you install jquery in your html code follow the jquery documentation to play with it.

Following is a sample html page where we installed jquery library in our html page:

<!DOCTYPE html>
<html>
<head>
    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
</head>
<body>
       <h1>Installing JQuery</h1>
</body>
</html>​

In above code, we added cdn url for jquery check out the following line in above html page.

<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>​

What is cdn url?

CDN known as content delivery network is basically proxy servers spread across the world. Lets understand the concept of data.

You have a website hosted on a webserver. Your server is located in toronto. Your website is seen by many people across the world.

When this users visit your page all assets you serve on your website for example: css, javascript, images etc. if they are hosted on your server they have to be downloaded through your server residing in toronto.

If a user from india is accessing your website. Your website takes a little longer time to download this assets as they are hosted on toronto based server.

Using cdn if you serve your assets then your website speed will be improved. How? Well, now you that cdn's are basically proxy servers spread across the world.

Which ever server is located to user's country your assets will be downloaded from that proxy server instead of original server located in toronto.

Similarly, jquery also provides cdn so that you can use the cdn url in your website directly.

Disadvantage of using cdn

One of the disadvantage of cdn is that if file hosted on cdn is unavailable because of server failure your website will no longer have access to that file and your website might break.