Live data from Hacker News

I loved jQuery, and still do (2019)

withblue.ink

41–50 of 189 posts

Re: I loved jQuery, and still do (2019)

#42
post #5

jQuery is still my bread and butter for DOM manipulation and events. I've found it to be much more readable than vanilla JS.

That's 30KB over the network and 90KB of JS code in memory so that you don't need to learn about 5 standardized browser API methods that are the same in every browser going back to IE9 then. No doubt that gives you a better developer experience but I don't think your users are thanking you.

> That's 30KB over the network and 90KB of JS code in memory

A fair point, but compared to the payload of most sites (let alone apps) these days that is chicken feed.

Just opened that page itself and DevTools tells me 5.2Mb was transferred including ~175KB of JS from twitter, 65Kb JS for the video player (which seems to have 46Kb worth of css associated with it!), ~1Mb worth of font resource, ...

> so that you don't need to learn about 5 standardized browser API methods

That and the way jQuery does method chaining, which a lot of people find far more convenient, but other features. jQuery does a lot more than querySelector/querySelectorAll/friends.

> No doubt that gives you a better developer experience*

And here we see a forum commenter in its natural habitat, hunting the point. It sidles up slowly, and pounces...

(with apologies for failing to resist being facetious and slightly dickish there)

>* but I don't think your users are thanking you.*

I don't think most users will notice. Those that do due to slow connections, metered connections, low-power/low-memory devices, etc, are going to baulk at much more before even noticing jQuery on this site.

On something like HN (23.8K transferred for this page before my comment was added) 30Kb might look chunky, but few sites are remotely close to being as lean as HN.

Re: I loved jQuery, and still do (2019)

#44

Earlier quoted context omitted.

Can you elaborate on what JQuery does for you that you can't do with modern JS features such as fetch and query selectors?

This page gives a pretty good overview of why jQuery is still relevant: http://youmightnotneedjquery.com/ Requests have gotten better with "fetch", but unfortunately, the "modern" DOM API is quite bad in some parts, making lots of stuff unnecessarily verbose. On top of that, it's really odd that the DOM API is not compatible with for-of loops, which could have been a selling point.

>it's really odd that the DOM API is not compatible with for-of loops, which could have been a selling point.

I'm not sure what you mean by that? querySelectorAll returns an iterable. Also, your link is outdated. It doesn't include the fetch API which has enjoyed wide support for quite a while now.

Re: I loved jQuery, and still do (2019)

#45
I still use jQuery even for new projects. Yes, these days it's possible to do everything jQuery does using native JS, but I find the native version to be much more verbose and its naming conventions to be far less clear.

For example, natively getting a list of children is `el.children` but natively getting the parent is `el.parentNode`, not `el.parent`. Meanwhile, natively getting a list of classes is `el.classList`, but when I'm getting children I also get a list, so why not `el.childList` instead of `el.children`? Natively cloning a node is `el.cloneNode(true)`, so now I have to remember what `true` is for and whether I want it or not (surprise: the default changed between JS versions, so the "optional" argument must always be included for compatibility!). Probably the most commonly used line in web JS in jQuery is the terse `$('selector')` but natively is the mouthful of `document.querySelectorAll('selector')`.

So while jQuery isn't strictly necessary, it's certainly a nice syntactic sugar, and IMHO a more sane and consistently-designed API than native. It's a great choice for developers who want avoid big frameworks like Vue and get as close to plain HTML/JS as possible, but still want a pleasant JS development experience.

Re: I loved jQuery, and still do (2019)

#46

jQuery is still my bread and butter for DOM manipulation and events. I've found it to be much more readable than vanilla JS.

Can you elaborate on what JQuery does for you that you can't do with modern JS features such as fetch and query selectors?

jQuery has the most consistent return values I've ever seen in an API. It somehow always works. Contrasted to that the fact that a NodeList is not an Array gets me every time.

Re: I loved jQuery, and still do (2019)

#47
post #5

Earlier quoted context omitted.

That's 30KB over the network and 90KB of JS code in memory so that you don't need to learn about 5 standardized browser API methods that are the same in every browser going back to IE9 then. No doubt that gives you a better developer experience but I don't think your users are thanking you.

> That's 30KB over the network and 90KB of JS code in memory A fair point, but compared to the payload of most sites (let alone apps) these days that is chicken feed. Just opened that page itself and DevTools tells me 5.2Mb was transferred including ~175KB of JS from twitter, 65Kb JS for the video player (which seems to have 46Kb worth of css associated with it!), ~1Mb worth of font resource, ... > so that you don't…

(with apologies for failing to resist being facetious and slightly dickish there)

No apology necessary. That was funny. Because it's true. :)

Re: I loved jQuery, and still do (2019)

#48

I had a big post but deleted it all. I can more concisely say this: The people here saying they still use it have so far demonstrated what I always say. If you're using jQuery, it's time to go back and relearn javascript. Most people should REALLY research the querySelector and querySelectorAll DOM methods. I've always felt that jQuery encourages you to let your skills stagnate and you don't learn what your code is a…

For new projects I agree. Go jQuery-less.

But for existing projects that still work well and for which there is no reason or gain from updating the code and, for which, time and money would be spent for what is really a lateral move, I think it's fine to leave it as is.

And there are many projects like this where the JavaScript barely changes, jQuery is holding it in place and nicely and there's hardly any technical debt. There's no incentive to spend the money and time. Making a developer feel better is not really worth it in these situations unless they'd like to work for free.

Re: I loved jQuery, and still do (2019)

#49
Some people talk big about dropping jQuery and saving one request, yet they have a shipload of bloat elsewhere. Not using jQuery in and of itself is not an optimization of any kind. I use jQuery and my page has a perfect score in GTmetrix. If the goal is optimization, you have to consider the total package.

Addititionally, jQuery loads on the first request and sits in local cache thereafter. And it could already be in local cache if you use a CDN.

Re: I loved jQuery, and still do (2019)

#50
post #32

jQuery used to be (necessarily) bloated because it needed to support so many poorly-behaving browsers. Now that these browsers are no longer relevant and support has been removed from jQuery, what is the performance hit, if any for using jQuery as opposed to vanilla JS? I agree with many, I find the jQuery syntax to often be better than the alternative.

Jquery minified is 83KB. That's about the size of a compressed 300x300 px JPG.
Post reply on HN