Why do you use jQuery in 2019?
Vinicius Brasil

Vinicius Brasil @vinibrsl

About: Building cool stuff with Elixir, OTP and Ruby. Majoring in Theology and musician. Engineering at @plausible

Joined:
Aug 10, 2018

Why do you use jQuery in 2019?

Publish Date: Apr 9 '19
14 18

JavaScript has matured a lot in the last years, and IMHO, jQuery has become irrelevant for me.

But that's not a reality for every developer, as the Stack Overflow Developer Survey Results 2019 has shown that 48.7% of the developers still use jQuery.

With a much easier and mature JavaScript, why do you use jQuery? What are the uses that vanilla JS can't do easily?

Comments 18 total

  • Tyler V.
    Tyler V.Apr 9, 2019

    I have no evidence to back this up, but I'd be willing to guess that it's not about what jQuery does that vanilla can't do easily, so much as one of the following:

    • Supporting a legacy codebase
    • Not knowing that vanillaJS has feature {x}
    • Familiarity with JQuery - For example: If you had to choose between looking up how to do something in vanilla or already knowing how to do it in JQuery, which would you choose?
    • Jason Towle
      Jason TowleApr 9, 2019

      Can't argue with the above. Spot on!

  • Ryan Smith
    Ryan SmithApr 9, 2019

    It is in place in a legacy app, but I have been trying to use more standard JavaScript. I came across this GitHub repo with some good examples to help in going from jQuery to standard JavaScript github.com/nefe/You-Dont-Need-jQuery

  • Antonio Radovcic
    Antonio RadovcicApr 9, 2019

    It still has some advantages. If you do

    const a = document.querySelector(`a`)
    

    And then try to use a, it will throw an exception. With jQuery it just fails silently. This can be a pro or a con depending on your use case.

    Also a good thing to use it for is when you receive a bunch of HTML in a string from a server and want to insert it into your document.

  • Daniel Schulz
    Daniel SchulzApr 9, 2019

    We sell most of our projects based on a system that uses jQuery. So yeah, legacy codebase.

  • Luke Plant
    Luke PlantApr 9, 2019

    There are still quite a lot of things that jQuery provides that are not one-liners in Vanilla JS. For example - serialize, and event delegation with on. And then dozens of other bug fixes and conveniences.

    Of course, you can implement these things yourself in Javascript, but why should you do that? Are you sure that copy-pasted code you found on the internet really works correctly on all browsers, or was it an 80% solution that got lots of upvotes on StackOverflow by people that didn't test it very thoroughly? Do you want to have to learn a hundred different browser gotchas the hard way, and is that really a good use of your time?

  • Adam Whitlock
    Adam WhitlockApr 10, 2019

    I would say legacy codebases. Mostly WordPress themes with jQuery libraries. I still enjoy using jQuery for quick fixes and getting stuff done easily. If it is already in a project, then I see no reason not to use it. Otherwise if I can I will use just vanilla and Vue.

  • Erik Skoglund
    Erik SkoglundApr 10, 2019

    Bootstrap depends on it.

    • Jason
      JasonApr 10, 2019

      I second this. Most of my projects depend on Bootstrap

      • Jesse R Davis
        Jesse R DavisJun 18, 2019

        Bootstrap is stripping out JQuery in the next version and moving to vanilla JS

  • Rohov Dmytro
    Rohov DmytroApr 10, 2019

    48.7% of the developers still use jQuery

    Years and years of being in dominance.

    But I was still surprised by this number in 2019!

  • Drew Knab
    Drew KnabApr 10, 2019

    Legacy codebase. The library is still loaded up on every page. May as well use it, and mixing up querySelectorAll() and $() in the same application sounds like a recipe for disaster.

    It's just not a priority to do massive rewrites just to expunge jQuery. If I started a project from scratch today, no, I wouldn't use it.

  • jojoshua
    jojoshuaApr 12, 2019

    I use jQuery because it is a library that performs very well and helps me do things in a pragmatic way. No doubt that JavaScript has gotten better but there are things that can be done via jQuery which are more elegant and easier to maintain. You write and application once and maintain it forever. There is nothing wrong with jQuery in 2019 or beyond. Web developers use dozens of libraries to make their lives easier. jQuery is no different in this regard.

    It's fine if you can or want to write applications without jQuery but don't expect a gold star just because you didn't.

  • Garvin
    GarvinApr 13, 2019

    jQuery is more than just a bunch of features. It is also an opinion on how to do things. For example if you want to hide an element in vanilla JS do you use visibility or display?

    For someone who has used jQuery for a long time, pulling in an 80K library and calling $('elm').hide() just makes sense. If jQuery is still supported, they get the performance they need and behavior they expect why should they change it? Wouldn't it make more sense to spend their time focusing on delivering value to their users?

    jQuery also has a rich ecosystem of plugins an extensions that would be a pain to reproduce if you decided to migrate everything to vanilla js. Again you have to decide what is the most valuable use of your time.

    It is understandable why people get excited about new technology but sometimes we forget why we are doing it. I would be more likely to shift from jQuery to a framework for code organization and maintainability than I would to vanilla js just because I can. The users of your site don't care if you use $() or document.querySelector.

  • Anton Tikhomirov
    Anton TikhomirovJun 20, 2019

    JavaScript is easier and mature?! I'm so sorry, but do you know JavaScript? How can document.getElementById ('elem') can be easy than $('#elem')?

    • Vinicius Brasil
      Vinicius BrasilJun 20, 2019

      I do know JavaScript, and I do know that document.getElementById ('elem') is not equivalent to $('.elem').

      jQuery dates from a time when vanilla JavaScript was hard to use because of browser compatibility. The vanilla JavaScript we have today is much more mature than 10 years ago, when jQuery was a must have.

      Being mature is not about having smaller function names to do X.

      • Anton Tikhomirov
        Anton TikhomirovJun 20, 2020

        Sorry for forgot to answer you. Okay, document.getElementById ('elem') is $('#elem'), it's my mistake. So can you give the "more mature" JS examples which is more compact than jQuery?

  • Mario Vivanco
    Mario VivancoJul 14, 2019

    Well. I am looking how to make a Photo Gallery with coding, and I find some jQuery app for this. I know that I can do with Lightroom, with only CSS also, but which other library more updated can give me a photo gallery component? react? vue? angular?

Add comment