I loved jQuery, and still do (2019)
41–50 of 189 posts
Re: I loved jQuery, and still do (2019)
#42jQuery 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.
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)
#43It was a great library for what it did and it holds up a lot of sites still.
Re: I loved jQuery, and still do (2019)
#44Earlier 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.
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)
#45For 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)
#46jQuery 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?
Re: I loved jQuery, and still do (2019)
#47Earlier 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…
No apology necessary. That was funny. Because it's true. :)
Re: I loved jQuery, and still do (2019)
#48I 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…
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)
#49Addititionally, 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)
#50jQuery 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.