Reasons jQuery is My Favorite Javascript Library

Rate article down Rate article up 0 subscribe to cyberstream photos rss feed
Download the Opera: a fast, efficient, feature-packed, secure, personalizable web browser. Over the past few years there has been a growing hype cool effects "created only with jQuery and CSS3". But why is jQuery so popular? There are dozens of alternative JS libraries, yet jQuery is still the most popular. I'm going to attempt to explain this in this article, approaching it at a personal level.

Why I chose jQuery

1. It Has a Vibrant and Helpful Community

jQuery is an open source project and it is the fourth most-watched project on Github with, at the time of this writing, almost 12,000 watchers. There are numerous advantages to having such a large community. Firstly, the project makes more rapid development advances. Secondly, the documentation is better. Whenever you want to learn a framework or language, the quality of the documentation drastically affects how easy it is to learn and fix problems. Thirdly, if you encounter a problem with jQuery, you can ask questions on sites like Stack Overflow, or basically any web development forum, and there is a large, knowledgeable community waiting to help you. Additionally, because the jQuery community is so large and passionate, there are myriads of superb tutorials on the web demonstrating jQuery usage techniques.

2. It is Cross-Browser

Whether you want to use CSS3 selectors, animated the opacity of an element, or make an AJAX request, jQuery can do it for you in one fell swoop of code that will work in basically any browser used today.

3. It is No-Nonsense

Everything in jQuery is concise and to-the-point. Too many alternative libraries get caught up in wordiness. A simple animation in another library might be something like, LIBNAME.get('element').specialFX('fadeout', 500); jQuery, however, is as concise as it can get: $('element').fadeOut(500);

4. Chained Statements and Callbacks

Two fantastic features in jQuery are the chained statements and callback functions. Here's an example:
// notice how the statements are chained together:
$('#my-element').addClass('logged_in').fadeOut(1000, function() {
    // this function runs when the element is finished fading out
    alert('Thanks for logging in');
});

5. Plugins

If the core library, extensive though it be, doesn't have what you need, then it is extremely likely that someone has written a plugin to extend jQuery's functionality. Plugins are easy to write if you know Java-Script, and they integrate with the main jQuery library very well. If you want to see jQuery's easing plugin in effect, click "contact" at the bottom of this page and watch the form bounce in. jQuery also has additional libraries available like the jQueryUI library that allows you to add rich interactive effects and functionality to your HTML elements.

6. Small Library

The minified jquery.js file, when gzipped, is around 20KB. That is tiny for the amazing functionality the library offers. However, you can make jQuery load even faster. If you get it delivered by the Google CDN like this:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
...then there's a very high chance that the file is already cached in the user's browser since so many websites use jQuery. If that is the case, then it will load almost instantly.

Why People Might Avoid It

Some people don't want to use jQuery because they think it is bloated. I think that is because when they see the amazing level of functionality jQuery offers, they think it is bloated. However, in reality, it is written very concisely and is amazing small, as I just mentioned before. It still blows my mind how much is stuffed into that jquery.js file.

What might be nice...

...is to be able to configure a jQuery package like you can with Modernizr. However, I don't think it is a big enough demand to be worth the effort building it. The jQuery UI library, which I mentioned before, is very large though. In fact, it is so large that you never use the entire thing. You just pick the features you want to use in it and that's that.
A library that I think is worth mentioning if the animations part of jQuery is the $fx library. The minified version of $fx is less than 4 KB!!! I don't like $fx's syntax as much as jQuery's, but you might want to use it anyway if you are a bandwidth miser.
I only mentioned a few of the main reasons jQuery is advantageous. However, it has many other facets that you will love when you get acquainted with it.

Posted February 10, 2012 at 1:08PM by Eli Mitchell in jQuery, Javascript, Web Development with 1 responses

Post a comment!

Name:
Your website: (optional)
E-mail:

Your comment: