开发者

JQuery will not exist in future? [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applica开发者_如何学Goble, visit the help center. Closed 9 years ago.

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?


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.


As others have mentioned, jQuery is more then a selector engine, it provides event handling, chaining, animations, UI toolkits, abstraction and a lot more. Take a look at the jQuery website.

Selectors by themselves aren't that useful. You use selectors to execute actions on those elements.

jQuery provides:

  • JavaScript abstraction
  • Animation
  • UI controls and widgets (Sliders, accordions, etc)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜