DEV Community

Discussion on: Do you still work with jQuery?

Collapse
 
nataliedeweerd profile image
𝐍𝐚𝐭𝐚π₯𝐒𝐞 𝐝𝐞 π–πžπžπ«π • Edited

Yes. No plans to refactor. It makes mine and my developer's lives a lot easier.

Our projects are LAMP stack and don't use modern JS frontends.

Collapse
 
ben profile image
Ben Halpern

I wrote this post years ago about jQuery at the time...

But have since come to think that it is effectively no longer needed (I think the fetch API put me over the top). Can you elaborate on what keeps you around the most?

Collapse
 
nataliedeweerd profile image
𝐍𝐚𝐭𝐚π₯𝐒𝐞 𝐝𝐞 π–πžπžπ«π

Predominantly the readability. I find jQuery a lot easier to read than JS.

I see this site referenced a lot: youmightnotneedjquery.com/ But all it does for me is prove how much I prefer jQuery!

Take the getJson function for example:

jQuery

$.getJSON('/my/url', function(data) {

});
Enter fullscreen mode Exit fullscreen mode

Javascript

var request = new XMLHttpRequest();
request.open('GET', '/my/url', true);

request.onload = function() {
  if (this.status >= 200 && this.status < 400) {
    // Success!
    var data = JSON.parse(this.response);
  } else {
    // We reached our target server, but it returned an error

  }
};

request.onerror = function() {
  // There was a connection error of some sort
};

request.send();
Enter fullscreen mode Exit fullscreen mode

I know which I prefer...

jQuery also comes with the added benefit of slideToggle() functions, fadeIn/Out() functions, etc.

And I can just $('.classname') to target something, rather than document.getElementsByClassName(className)... it's just such an effort to write that much.

Time is money, and jQuery helps me do what I need to do quicker ! :)

I appreciate my team and I would need to transition to Vanilla JS if we start to use more frontend frameworks, and we are looking to bring in Vue to some of our projects in the future. But our LAMP systems (Wordpress/Drupal/CodeIgnighter) are still our bread-and-butter projects, and using jQuery in them just makes our lives easier.

I'd also argue modern frontend frameworks are still mostly in their adolescent stages, where they're still trying to stabilise themselves/their role in the future of the web... Vue has been around for 7 years, React 8 years, and Angular only 5 years; whereas jQuery has evolved over 15 years and understands its place in the world.