This is the second in a series of technical blog posts contributed by VanHackers. Today’s post is by Lucas C.
Lucas is a Front-End developer with over 10 years of experience managing teams and programming complex applications. He has been consistently recognized for performance and being proactive. His strengths lie in leadership and logical programming.
You can check out his VanHack profile here – https://vanhack.com/vanhacker/132904
Do you want to write a blog for us? Click here
Picture yourself building a website ~15 years ago. 85% of the world used Internet Explorer and 10% Firefox (Google Chrome didn’t exist in 2005). The last version of ECMAScript was published in 1999 (version 3), and we never dreamed of things like NPM, TypeScript, Angular, React, Vue or Node.
Here’s what Google Trends looked like in 2005 when comparing these 3 libraries.
These kinds of libraries were used to create widgets (like calendars), make it easier to use AJAX, some event delegation, and of course, reduce code. It was quite common to write different code for the same feature to work on Internet Explorer and Firefox, for example.
In January 06′ things finally began to change, when a 22-year old John Resig was inspired by a selector JS library called “cssQuery” and had the brilliant idea to build jQuery at a BarCamp in NYC. jQuery revolutionized the market and quickly became very popular.
Google Trends shows just how rapidly jQuery got adopted by developers everywhere!
Have you ever wondered why? What was so magical about jQuery?
To the Code!
Let’s look at some examples to illustrate just why jQuery took over the world. I’ll write them in JS (ECMAscript 3) and then in jQuery.
Let’s say you need to build a feature: font-size accessibility. The brief is simple – click a button and increase or decrease the font size.
First in JS
Now in jQuery.
jQuery made it possible to manipulate the DOM using selectors like this. And removed the necessity for a “for” loop while still being able to add a function in the same line.
Imagine how happy developers were! This is incredible power. 🤣
Another big reason for jQuery’s popularity was the community that accreted around it. Many developers built plugins in jQuery and extended it. This created a fantastic community around this library. Here’s an example of one that I use one for many projects. It’s called jQuery.Mask. All you need to do is put the script above the jQuery library and write the following code.
And bam! auto masks in your form fields. This simple plugin can do a lot more, and save you tons of time.
jQuery changed Web Development forever
jQuery in 2020?
But is knowing jQuery still relevant in 2020? I’ve talked with many new developer, informally and in formal interviews. Many of them never used or even heard about jQuery!
It’s common to know React, Angular and Vue because these are the present and future of development. But we don’t live with just new projects or refactoring older projects. In many cases, it’s necessary to maintain and update an old project. Your customer/boss either can’t budget for an upgrade or doesn’t want to risk breaking a working project. Or both!
“All right, but we will never use it for a new project!”, you say.
I disagree a little with such blanket statements. In my opinion, every language, framework, or library exists to fill some need, however small it may be. Balance is essential and choosing with wisdom the better option, rather than just using the “flavor-of-the-month”.
I like to use jQuery, for example, to build simple websites, landing pages, or applications where I don’t need a lot of structure. It’s fast and solves my problem. In some projects, it’s completely unnecessary to use NPM, Yarn, Web Pack, Angular, etc. Sometimes (many times!), less is more.
Many people seem to agree with me. According to W3Techs.com, jQuery is used in 74% of all websites. This is proof you need at least know a little bit about this venerable but still extremely useful library.
So no, to answer my own question – jQuery is NOT dying in 2020 – or anytime soon.