from Hacker News

I loved jQuery, and still do (2019)

by notoriousarun on 6/29/21, 2:45 PM with 182 comments

  • by acabal on 6/29/21, 3:43 PM

    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.

  • by rchaud on 6/29/21, 3:58 PM

    Every time anything about jQuery is posted, someone will inevitably post the "You might not need jQuery" site. [0]

    I look at that site and laugh. Is this supposed to be making the case ~against~ jQuery? Maybe the audience for that site are seasoned developers for whom the vanilla JS syntax is easily understood. Everybody else is going to look at those code snippets and think jQ is the way to go.

    For people that have struggled through HTML and CSS, there is perhaps nothing more deflating than to realize that even basic UI interactivity requires JS. But with jQuery the code snippets needed are short and understandable. Vanilla JS in comparison looks like an entirely different language.

    [0] http://youmightnotneedjquery.com/

  • by legitster on 6/29/21, 3:23 PM

    I love jQuery.

    I can just drop in the library onto any existing webpage, and have almost complete control of the DOM with just a few lines of code. And the built in actions and animations are all so simple and perfect for the web. And the structure and naming is so good that I rarely need to look up any references anymore.

    I get that browser support isn't as important as it used to be, but it is nice to know that you can just use an effect in jQuery and it will just work exactly as you expect it.

  • by mortenjorck on 6/29/21, 3:50 PM

    I finally learned some React a couple of months ago on the premise that as a designer, I needed a better understanding of the frameworks used by the developers I work with.

    I know React enforces some better practices that my spaghetti-jQuery of yore never followed, and that I was getting a crash course in those practices at the same time, but I was nonetheless surprised at just how slow I felt working in it! It gave me a new appreciation of just how accessible jQuery is, and how intuitive its concepts are to someone without a background in software development, perhaps for better or worse.

    Obviously this is a bit of an apples-to-oranges comparison, given the intended uses of the two frameworks, but for simple projects, it's hard to imagine a better balance of accessibility and flexibility than jQuery.

  • by VWWHFSfQ on 6/29/21, 3:23 PM

    Django templates + Bootstrap + jQuery is all I've ever needed to make great, modern websites. Server-side rendering with some nice layouts and interactivity on the frontend. I've tried some of the SPA frameworks and I've always felt like my productivity tanked.
  • by cptrp2101 on 6/29/21, 3:33 PM

    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 actually doing. Learn what the current spec has to offer. You don't need another dep just to target dom nodes ffs.

  • by franze on 6/29/21, 3:14 PM

    I created box2d jQuery https://github.com/franzenzenhofer/box2d-jquery (Demo Pages sadly down) a physics engine for the DOM.

    I really learned to appreciate jquerys clean codebase at that time. Learned a lot about the DOM and how to misuse it.

  • by mkl95 on 6/29/21, 3:07 PM

    I'm not the biggest fan of jQuery because I have had to deal with massive tech debt created by other engineers over the years (and I'm not a frontend dev). However the Ajax API is a genuinely good tool.
  • by vlunkr on 6/29/21, 3:54 PM

    Do people still hate jQuery? I feel like the consensus is that that jQuery was a great tool for the time, but is not so critical today.

    Yeah, we've all seen spaghetti code monstrosities that involve lots of jQuery, but it's just a library, it can't be blamed for people not knowing how to structure their code.

  • by tossaway9000 on 6/29/21, 8:11 PM

    In 2012 or so we doubled down on jQuery UI, specifically the widget factory and a few dozen custom widgets extended from a custom parent widget. That application is STILL in production today, chugging along in both the private and public sectors.
  • by BlameKaneda on 6/29/21, 3:00 PM

    jQuery is still my bread and butter for DOM manipulation and events. I've found it to be much more readable than vanilla JS.
  • by developeron29 on 6/29/21, 3:27 PM

    Yes Jquery does makes things easier than vanilla JS

    Best being

    $("#id") replacing document.getElementById("id");

    Makes code look cleaner

  • by neals on 6/29/21, 4:48 PM

    JQuery and backboneJS were all I needed up until very recently. Now it's modules all the way down, alien syntax and overengineering.
  • by thoughtpalette on 6/29/21, 3:01 PM

    jQuery will always have a soft spot in my heart. I came from a design background and the naming conventions and "utility" functions for common events and selectors made it so simple to understand.
  • by bstar77 on 6/29/21, 4:01 PM

    I agree with the author that jQuery was essential for the time. Abstracting away browser compatibility issues in the era of IE6 was a wonderful thing, for sure.

    The problem is jQuery has no business being used today unless you have to maintain legacy code. Even then I would deprecate jQuery wherever possible. Using jQuery for a "quick and dirty" application today is just terrible and it sends the message to green devs that jQuery code slinging is a skill worth having.

    If you like quick and dirty, just make sure you have a working Node.js environment and generate a simple project that supports Webpack or Parcel. You will get all the advantages of Babel and Polyfills (if you need them) with little to no effort.

    jQuery has no value except for maintaining legacy code. jQuery was useful back in the day (and John Resig had the best solution), but I don't love it anymore. In fact, I have serious judgements of the devs that use it that should know better.

    Edit: I should note that jQuery is bad because it has no state management and you cannot easily track side-effects. I would much rather see someone use something like Svelte and construct the functionality with modern best practices while keeping a very small footprint.

  • by thera2 on 6/29/21, 3:46 PM

    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.

  • by warpech on 6/29/21, 3:54 PM

    I definitely agree with jQuery's legacy. We owe many parts of modern DOM and JavaScript to jQuery and Prototype.js (may I say that Prototype.js was to JavaScript what jQuery was to DOM).

    There is probably no reason today to use Prototype.js, however, jQuery still is a better choice than React/Angular/Vue for small projects if the author prefers some syntactic sugar over plain DOM.

  • by ChrisArchitect on 6/29/21, 3:14 PM

    They loved it still in 2019. How about since then?
  • by ricardo81 on 6/29/21, 3:33 PM

    I've depended on jQuery, not a strictly front end designer myself but have done a bit of client side dev the past 20 years.

    If I had a choice, I'd go with one of the reactive libraries, I've used Vue. For me, if you're relying on Javascript IMO it gets the job done quicker.

    It'd be interesting to see what jquery is used for in aggregation of all its usage. For me it was always selecting element(s) and XHR requests. With fetch (and a polyfill for IE), and the likes of querySelector it seems that a lot of the problems jquery solved have also been solved by the majority of popular browsers.

    I say that as a layman of client side dev, happy to be corrected.

  • by drummer on 6/29/21, 3:18 PM

    JQuery is a tour de force of API design. Still use it in all my web projects.
  • by mouzogu on 6/30/21, 9:18 AM

    NO, you can't use jQuery!! It's against the law!!! (proceeds to build non-interactive static page with create-react-app)

    I find jQuery and Bootstrap great for fast prototyping. The thing I love about jQuery is the cross-browser compatibility. I know things have improved but I have very little faith in native JS "just working" as I would expect on all browsers.

    But of course it was not designed for building reactive apps and so should not be used for that. It's nice just for fast-and-dirty UI interactions and animations.

  • by locallost on 6/29/21, 9:18 PM

    It's really a great piece of engineering -- it a technical building block that is very well designed and solves a great number of problems. Some of the things that came later put development on a new level, but this doesn't take anything away from jQuery for the time it was made. Resig's book is in a large part "how jQuery was made" and it was a great read. Also some of the built in APIs that mimicked it like querySelector are not as elegant as jQuery, even though it was a solved problem at that point.
  • by whalesalad on 6/29/21, 3:17 PM

    I am deploying Vue ui's now without webpack or any kind of bundler – jQuery and I have been through hell and back but I do wouldn't say I love it.
  • by cmer on 6/29/21, 3:30 PM

    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.

  • by nailer on 6/29/21, 5:51 PM

    > Although, at the time we weren’t really using the word “SPA”, and so we’d refer to that category of apps with terms like Rich Internet Application (RIA) or “Web 2.0 app”.

    'Rich Internet Applications' were not the same thing as web 2.0 sites. Rather, they were a precursor to modern concepts like Electron and webview2.

  • by mbostleman on 6/29/21, 5:55 PM

    > Then GMail came in 2004

    OWA and Ajax appeared 6 years earlier. Why would Gmail be considered the milestone instead?

  • by racl101 on 6/29/21, 3:42 PM

    Will never understand the snobbery against jQuery.

    It was a great library for what it did and it holds up a lot of sites still.

  • by princevegeta89 on 6/30/21, 12:24 AM

    jQuery is great, especially when you are low on time available and wanted to put together your product with minimal friction. VueJS, React etc. are great, but not when you have no more than 2 developers working. We are in the age of 5G internet and high bandwidth network streams, downloading a couple of hundred extra kilobytes of js files on mobile clients and desktop browsers should be no problem to at least 85% of the users.

    Oh and BTW it pairs really well with StimulusJS. I've used it thoroughly and it's been a godsend

  • by byteface on 6/29/21, 6:58 PM

    I guess it's easier to remember $ than queryselectorall . I recently realised most of its methods are now natively supported. I think people who don't use js a lot may not realise that.
  • by shmiga on 6/29/21, 8:24 PM

    It's like with smoking. Sure, you're writing jQ for decade it's hard to quit. I strated coding relatively late and I have no fucking idea why do you ever need jQuery.
  • by evo_9 on 6/29/21, 8:18 PM

    Any suggestions on a jquery-like easy to implement calendar control? That’s the one thing jquery still does better than everything else, at least that I know of.
  • by olliej on 6/30/21, 7:02 PM

    I recall people arguing that browsers should have jquery built in, because "it's clearly never going away"
  • by thrower123 on 6/29/21, 9:17 PM

    I still think they should have just shipped jQuery or lowdash with browsers as a defacto JS standard library.