Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery will not exist in future? [closed]

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 will not exist in future? Is it safe to keep JQuery in our websites for the next years?
like image 753
Junior Mayhé Avatar asked Oct 28 '10 00:10

Junior Mayhé


3 Answers

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.

like image 172
Nick Craver Avatar answered Nov 05 '22 21:11

Nick Craver


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.

like image 20
jpsimons Avatar answered Nov 05 '22 22:11

jpsimons


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.

like image 29
Christian Mann Avatar answered Nov 05 '22 20:11

Christian Mann