A number of other libraries came out around the same time such as MooTools and Prototype but there’s a number of reasons why jQuery has surpassed them in popularity.
Reuse of CSS Selectors
jQuery came out around the time web designers and front-end web developers were getting used to creating table-less, semantically marked-up web pages. It was a lot of effort to switch from one way of coding to another. CSS was being learned by the web community en masse.
jQuery used the same CSS selectors that people were using for styling their pages to add behavior. There was no context switching when referring to the same elements.
jQuery also implemented many of the CSS3 selectors prior to browser implementations. This meant you could apply behaviors to elements you couldn’t necessarily select with CSS yet! You didn’t feel you were wasting your time learning new selectors as they’d be eventually supported by modern browsers. In most cases these selectors are widely supported today.
Unobtrusive by Design
Not only did jQuery emulate CSS with it’s selectors, it also employed the same separation from content.
If you want to hide all paragraph elements with the class of
.spoiler call the
But what if you want to remove elements from the DOM? That’s right, you call the
It’s the principle of least surprise, both because you’re using pre-existing CSS knowledge and because of jQuery’s simple method names. You’ll find yourself guessing methods rather than looking them up in the documentation. When you do go to the documentation there’s plenty of example code to see each part of the jQuery API in action.
By its design, jQuery has allowed novices and pros to improve the experiences of countless numbers of users. It took the impossible job of thinking about both the end-user and the developer and made something that checked all the right boxes.
jQuery is a testament to John Resig and team’s ingenuity. I can’t imagine how much fun I’d have missed out on without jQuery in my toolbox.
Do you use jQuery? Why do you think it’s so popular? I’d love to hear your opinions in the comments below.
I am just being introduced to jQuery, but I can tell that it is going to simplify my life and make coding much expansive and fun.
That may be quite attention-grabbing, You are an exceedingly skilled tumblr. I’ve became a member of a person’s rss feed and check forward to around goal of excess of the great submit. As well, I’ve truly embraced your website around my web sites
For my opinion, jQuery is most popular library, because she provide very important thing like:
– You do not need to know a lot of things are happening under the hood. It’s like a machine, you only need to press the start button and press the gas pedal, the rest of the library will do for you.
– Using css selectors it’s very impressive, you write less and take what you need in one string
– Chain pattern also, very impressive
– Don’t worry about work in a lot of browsers
Great points Andrew!
You briefly mentioned it, but the fact that the community and supporters of the jQuery codebase have kept the documentation up to date and accessible is one of the major reasons why it gained so much traction. Sometimes open source frameworks think of the documentation as being secondary (you have the code after all, right?) However, well maintained documentation is vitally important.
Another reason jQuery has been so strongly adopted is due to the fact that it hides all of those crazy browser inconsistencies, especially with the versions of the browsers that existed at the time of jQuery’s initial release. No crazy checks littering my code to determine what the user agent was.
Finally, jQuery code has supporting unit tests that ensure that the code isn’t going to break due to an update to the core libraries. This, coupled with the fact that the release notes are well maintained makes adoption and upgrading a much easier task.
I love jQuery, cause it is simple and flexible 🙂