Why jQuery?
jQuery was launched in 2006, at a time when the most used Javascript Apis were not 100% compatible among browsers. This jQuery compatibility layer ended up with that 90% of the top 1,000,000 of websites in the world use this library. It’s a very expressive number.
jQuery usage data among the most visited sites in the world.
The big point of jQuery is not the compact syntax, but the compatibility between browsers. Doing a critical analysis, the syntax of jQuery is not at all clear: you can’t say what $("#abc")
is making.
Pure Javascript
But Javascript has evolved, consolidated, and matured over the years. It has a specification (ECMA-262) well defined, and today, followed by the navigators. Before this was dream.
Today, making an HTTP request with pure Javascript is very simple:
var request = new XMLHttpRequest();
request.open('POST', '/my/url', true);
request.send(data);
Another facility of jQuery are the animations, however, in 2019, this is much better executed with CSS, by using GPU and not CPU for some things.
@keyframes fadeIn {
0% {opacity: 0;}
100% {opacity: 1;}
}
And the compatibility problem between the browsers was solved both by the maturation of the language and the specifications, but also by the compilers, such as the Babel. It transforms:
[1, 2, 3].map((n) => n ** 2)
in
[1, 2, 3].map(function (n) {
return Math.pow(n, 2);
});
jQuery is still needed?
In fact, jQuery was needed, such that 90% of the world’s top 1,000,000 sites used it. It was impossible to program for each Javascript engine of 2006. But today, there are better, more performative, and more elegant alternatives to solve the most critical problem: compatibility. Maybe you don’t need jQuery.
Verbosity is not necessarily bad. And simplicity is not necessarily good.
jQuery is not and never was necessary. It has never gone from a convenience.
– Vinícius Gobbo A. de Oliveira
I changed the title and put the necessary in quotation marks. I know it was never necessary, but I have the impression that nowadays it is much easier to disregard it in new implementations. I was hoping to find arguments to the contrary...
– Marcus Vinicius
I’m reopening the question by understanding that the question is about compatibility between modern browsers.
– bfavaretto
Therefore and to achieve technical arguments, not based on opinion, to adopt jQuery in new projects.
– Marcus Vinicius
As for IE, classList only works on IE10 onwards and partially! http://caniuse.com/#feat=classlist If you care about older browsers, jQuery is great for taking care of crossbrowser differences
– user622
Related http://answall.com/q/46983/101
– Maniero