Live data from Hacker News

Why do yo use JavaScript-Libraries like jQuery?

news.ycombinator.com

1–10 of 17 posts

Why do yo use JavaScript-Libraries like jQuery?

#1
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.

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 >9.x.

So I asked me: For which reason are most of the web developers using jQuery? I mean: Selecting DOM elements isn't an argument, Element.querySelector should be faster. AJAX complexibility isn't an argument, ActiveXObject is dead since IE 7. Animations aren't an argument, CSS 3 is grown-up. Since ECMAScript 5, there's Array.prototype.forEach. Events can be easily handled by CustomEvent.

If you're interested in these native APIs called WebAPI, just take a visit to MDN: https://developer.mozilla.org/en-US/docs/Web/API/Element.querySelector https://developer.mozilla.org/en-US/docs/Web/API/element https://developer.mozilla.org/en-US/docs/Web/API/Node https://developer.mozilla.org/en-US/docs/Web/API (Everything at a glance)

Re: Why do yo use JavaScript-Libraries like jQuery?

#2
"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.

Re: Why do yo use JavaScript-Libraries like jQuery?

#3
Taking a quick look at the source code directory structure 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.

Re: Why do yo use JavaScript-Libraries like jQuery?

#5
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.

Re: Why do yo use JavaScript-Libraries like jQuery?

#6
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.

Re: Why do yo use JavaScript-Libraries like jQuery?

#7
post #6

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 bandw…

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.

Re: Why do yo use JavaScript-Libraries like jQuery?

#8
post #6

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 bandw…

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.

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

Re: Why do yo use JavaScript-Libraries like jQuery?

#10
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.

Post reply on HN