DEV Community

Cover image for Story of jQuery, Write Less and Rest in Peace
Adnan Babakan (he/him)
Adnan Babakan (he/him)

Posted on

Story of jQuery, Write Less and Rest in Peace

Hey there DEV.to community!

Once I published a post about that I don't know jQuery anymore which you can check the post here:

Here I will tell you my explanation of why did jQuery is dying and maybe is dead already. And some of jQuery's hisotry.

What is jQuery and how did it become so popular?

jQuery is a free open-source JavaScript library used for designing web and it was the most popular library back in its days. No one would imagine a web page without jQuery! It was first released on August 26, 2006 which makes jQuery a 13 years-old library thus a mature one.

Using jQuery you can write less code and do more (it is their slogan). Have the example below:

Vanilla JavaScript:

<button id="myButton">Click por favor!</button>

<script>
    function buttonEventHandler() {
       alert('Say Hi to VanillaJS!')
    }

    document.getElementById('myButton').addEventListener('click', buttonEventHandler)
    document.getElementById('myButton').addEventListener('dblclick', buttonEventHandler)
</script>
Enter fullscreen mode Exit fullscreen mode

Now have it in jQuery:

<button id="myButton">Click por favor!</button>

<script>
    $('#myButton').click('click dbclick', function() {
        alert('Here we go with jQuery!')
    })
</script>
Enter fullscreen mode Exit fullscreen mode

Cool, right?

This why people loved jQuery, it got them out of the torture sometimes JavaScript might put people in back then.

You can check more samples about jQuery and Vanilla JS in my post linked above.

JavaScript is killing jQuery

It is pretty hard to believe to destroy what you've made yourself but it is real. JavaScript is the language jQuery is written in but on the hand JavaScript eventually began to grow and adapt more features that people started to feel less needing jQuery. For instance fetch API which tookover XMLHttpRequest and made it really easy to make AJAX calls and so many more examples.

So when you have something already built-in why would you add some more weight to you webpage? So there was performance issue. jQuery eventually became heavier and heavier since they were adding new APIs.

No clean architecture

As for myself, I always felt pretty bad how I'm writing jQuery and I've some other programmers about it and they were surprised about our mutual feeling. Some might say it is a programmer's fault if they are not writing clean code but I say it is a libraries design pattern fault as well. jQuery had no clean architecture and let you write your script you as you like which sometimes caused in bad practice code.

Rise of new JavaScript libraries/frameworks

Rise of new JavaScript lirbraries/frameworks such as Vue, React and Angular was a big bang for the universe of web development. They made thing much easier to do which jQuery couldn't accomplish by then. They also partially solved the architecture problem, they provided a way to write a cleaner code, you can write bad code using them though but at least it is much less probable.

Single page apps

SPAs (or Single Page Apps) is a relatively new way of designing web apps which is not possible by using jQuery so more and more websites had to drop jQuery when they switched to a SPA technology.

SPAs needed a data layer to bind some data and change them consecutively which was not possible with jQuery or would require a lot more work to do, to be more precise.

CSS is becoming more powerful

This might be the most irrelevant one you'd think but I think it impacts the way jQuery is heading to now. jQuery used to be a popular tool to animate web page elements which wouldn't be possible with CSS. CSS is not becoming more powerful and you can implement many animations using plain CSS without the need of jQuery.

One of the most things programmers used to do was using jQuery to calculate some layouts' sizes, CSS now supports calc function which does almost 90% of the job needed.

I've seen some programmers using jQuery as their CSS variable holder so they can change colors of a web page based on a value in their JavaScript, but CSS nowadays support variables and is very much convenient to use.

Is jQuery currently demanded?

Yes and no! If you are starting a new proejct or getting hired for a new one the chance of needing jQuery is less than 10%, but you better keep in mind lots of websites which are built on some legacy code might still need jQuery since converting them would be a real pain.


These were my reasons why jQuery lost its popularity or as they say it died.

Tell me your opinion about this matter in the comments section below!

I hope you enjoyed!

Top comments (1)

Collapse
 
marcusatlocalhost profile image
Marcus

If you find yourself writing helper functions to simplify stuff, then jquery (or smaller clones of it like: github.com/fabiospampinato/cash) are a valid option - your first example shows how much less you have to write.
And as you pointed out yourself, jquery is still used in millions of legacy websites that aren't going to be refactored or rewritten in a "modern framework" any time soon, if ever.
I rather work on a site with jquery, than some early Angular 1 monster (which was a modern framework once) - use the tools that help archive your goals. Cheers.