I was checking out HTML5 new javascript commands and there is something similar to:
var els = document.querySelectorAll("ul li:nth-child(odd)");
This allows you to find all elements by css syntax. But I sure Jquery also has something a little similar to this.
The question is, as browsers are getting better javascript APIs...
jQuery does a lot more than just the selector engine (Sizzle), and Sizzle uses querySelectorAll()
if it's available since the version included with jQuery 1.4.3.
No, it's not going anywhere, the selectors are only one piece of the puzzle.
It's true that jQuery is a lot more than just a selector engine. But it does seem like a lot of what else it does might become obviated by bleeding edge browsers, for example:
Animations
jQuery's Effects such as animate(), fadeOut(), etc are taken care of by CSS transitions.
Ajax
jQuery takes care of abstracting browser differences, such as using ActiveXObject("Microsoft.XMLHTTP")
instead of XmlHttpRequest()
in older versions of IE. This fallback is quickly becoming unnecessary.
jQuery's Ajax also provides JSON-P for cross-domain Ajax. This won't be necessary with proper cross domain XmlHttpRequest as implemented in the latest browsers.
Event binding
jQuery abstracts away IE's attachEvent
vs everyone else's addEventListener
. But since IE9 will provide the standard method, that abstraction will also become unnecessary.
This all means that "dropping down to raw JavaScript" will become less barbaric than in the past. However, it's still nice to have the library. Take jQuery's central genius, the idea of sets acted upon in parallel. In jQuery you write:
jQuery("#something").hide();
In raw JavaScript you write:
var things = document.querySelectorAll("#something");
if (things.length > 0) {
things[0].style.display = "none";
}
This kind of grace will never be fully available from builtin DOM methods.
Of course it's safe to keep JQuery on our websites. Remember, you link to the library, and that's based off of Javascript. It doesn't require any special software on the client side (apart from Javascript).
As for JQuery being obsolete in the future, no no no no no. It does so much more than just selectors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With