Why Use jQuery?


Why use jQuery?

I get asked all the time: “Why use jQuery?”.  The official motto states it simply: “write less, do more”.  Now that I got all these official and quoted statements out of the way, we can get into details.  jQuery is an extension of JavaScript and a JavaScript library.  All modern browsers interpret JavaScript, which in turn, interpret and load the jQuery library (via linking it in <head>).

The official jQuery page  says that jQuery is “a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript”.  A lot of people don’t realize that different browsers (especially Internet Explorer) render pages differently.  Unfortunately, this causes lots of headaches for us developers because, before jQuery, we had to write custom code to handle these nuances.  Now, we can simply just write our logic and the library will handle 98% of these differences.  This is very important for businesses that want to make sure their site looks the same to all customers no matter what browser they are using.

jQuery also allows developers to easily traverse and select HTML elements from the DOM (Document Object Model).  We can select one element or multiple elements and return an array.  jQuery selectors are based on CSS syntax.  Any web developer should know most CSS selectors and it makes our jQuery code that much more readable.  Selectors are the foundation of jQuery.  Most everything is built off of these selectors.  You can handle certain events based on these selectors, dynamically change the styling of these selectors, manipulate other elements based on your selector, traverse the DOM with ease, and simply do more by writing less code.

There are many other things you can do with jQuery and I just scratched the surface in this post.  If you are a new developer or just a techie, it would be advantageous of you to go to jQuery.com and learn more about this amazing JavaScript library.