

Why do yo use JavaScript-Libraries like jQuery? - barnslig

jQuery was released in January 2006. At this time, IE6 was the major browser at the market, so everything concerning to JavaScript was a bit messed-up with Microsoft specific stuff, Firefox market share was growing, the need for animations combined with CSS 2 came up etc. pp.<p>Today, we have our browsers in a who-is-most-standard-compliant-competition and a lot of nice new APIs with most of the basic ones even supported by IE 8, so most of them have higher backwards-compatibility than jQuery 2.x, which officially only supports IE &gt;9.x.<p>So I asked me: For which reason are most of the web developers using jQuery? I mean: Selecting DOM elements isn&#x27;t an argument, Element.querySelector should be faster. AJAX complexibility isn&#x27;t an argument, ActiveXObject is dead since IE 7. Animations aren&#x27;t an argument, CSS 3 is grown-up. Since ECMAScript 5, there&#x27;s Array.prototype.forEach. Events can be easily handled by CustomEvent.<p>If you&#x27;re interested in these native APIs called WebAPI, just take a visit to MDN: https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;API&#x2F;Element.querySelector https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;API&#x2F;element https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;API&#x2F;Node https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;API (Everything at a glance)
======
mschuster91
The biggest reason to use jQuery is the extensive ecosystem. Nearly every JS
problem has a jQuery extension-based solution.

------
esailija
You are mistaking jQuery for a querySelectorAll alias, I have no words for how
wrong that is.

~~~
justbaker
+1. Dear lord..

------
gpsarakis
Taking a quick look at the source code directory structure
[https://github.com/jquery/jquery/tree/master/src](https://github.com/jquery/jquery/tree/master/src),
I believe that you could create a minimal, customized build containing only
features that you actually want. For example only element selection (which is
very convenient and fast IMO) and AJAX.

------
smoyer
"Selecting DOM elements isn't an argument"

I think this is actually the remaining argument. JQuery was the best at
selecting DOM elements and grew from there. I think the question now is
whether you find enough value in the other parts of JQuery to include its
(rather massive) .js file.

~~~
ElongatedTowel
You can use the selection engine as a standalone.

[http://sizzlejs.com/](http://sizzlejs.com/)

------
27182818284
Practically everything I can think of needing on a daily basis has a solution
already made and tested in jQuery. Very rarely do I have to reinvent the
wheel, be it tablesorting, an AJAX-sourced type-ahead box, or a nicer date
widget. That saves time and effort.

Its ubiquity also means that problems are often already solved in it. Every
time I've run into a jQuery bug there has been discussion and work-arounds
already posted online by people much smarter than myself.

------
nailer
there's still no nodeList.prototype.forEach. You can(and should) make it but
it's pretty sad qsa was implemented without fixing the most basic thing about
its result.

Also jquery neatly abstracts single/ multiple element operations making for
shorter code.

Use jquery 2, it's tiny and gives you the tenseness without the extra code for
all the old stuff.

Or cut a few pixels from the top of a single image and save bandwidth that
way.

~~~
goldenkey
jQuery still lacks the ability to select for just a single element. That makes
it horribly inefficient for id selectors among other single-element cases.

~~~
nailer
Sure, and if DOM selector performance is a issue, you should consider ditching
it.

------
borplk
You are underestimating how much work jQuery does for you.

------
ghostdiver
Dependencies, unfortunately I am forced to use it, because it's just there in
the code used by someone few years ago.

Plugins are not the reason and fortunately it is changing already, because
UI/UX feature developers do not want to be jQuery plugin vendors anymore, they
want to promote their stuff under their own brand.

------
Bahamut
jQuery has a lot of useful things, such as a good selector engine (although
can be inefficient if you abuse it), lots of easy to hook into plugins, and
helpers such as `scrollTop()` & `$(window).on('resize', ...)`. I'm a huge
proponent of Angular, but jQuery still has its utility.

------
justbaker
Here is a reason why.. [http://jsperf.com/queryselectorall-vs-jquery-
jb](http://jsperf.com/queryselectorall-vs-jquery-jb)

------
MildlySerious
I'm pretty sure people also test a lot less when using jQuery. It's a
convenience thing.

------
jbeja
One word: "Plugins".

