Why one should love jQuery ?

Why one should love jQuery ?

jQuery was majorly using earlier. Now it seems like everyone is avoiding it in modern JavaScript development. Even most of the developer is moved jQuery to JavaScript to improve their JavaScript skills in order to avoid the use of jQuery and another reason is, it is the base for JavaScript frameworks. Developers have the impression that jQuery will die soon and in the future, only frameworks and vanilla JavaScript will be used.

jQuery doesn’t make your site slow

One of the biggest reasons to avoid jQuery I heard is that it adds unnecessary files to your site which takes enough time to load. However, the truth is the file-size not big enough to slow down your website.

jQuery is cached from a CDN and being used in many websites already. This means using jQuery is essentially free as fas as your bandwidth is concerned. So, practically it won’t slow down the loading time of your website in any meaningful way.

Even if you are not using the cached version, jQuery slim minified + gzipped is only about 27KB in size and the full version of jQuery is only about 6KB more as compared to the minified version.

Webpack externals are great

One of the best things available at the present time is bundlers. Webpack is a staple of modern JavaScript development, and you should be using it in your projects. There are also many other bundlers available and you can use them according to your choice. As the best jQuery practice to avoid the unnecessary loading you can use the jQuery as an external library and you can import it into your modules where needed.

It’s 2020 and you’re a little behind if you are not using a bundler like webpack. The very basic configuration of webpack will give you ECMA 2015+, which means modules for scalability. This is also good as it provides easy uglification for production environments. If you are using custom JavaScript or jQuery and not using something to minify/uglify your code for production, I’m not quite sure about your priorities.

jQuery makes writing code faster

Time is valuable for everyone, and clients perceive value in the number of productive features you can implement within a number of billable hours. Instead of writing the lines of code, it’s better if you can writing the shortest possible code using jQuery. It will save your time and you can spend that time elsewhere and you will undoubtedly start demonstrating significant productivity advantages as compared to other developers who don’t want to use the jQuery.

You should still be aware of slow code

Due to ease of learning and understanding, jQuery one can start writing the code in less time, this may lead to writing very inefficient code in jQuery. The extremely low barrier to entry means there is a huge amount of very bad code. So, as a best practice, one should properly learn the jQuery from the official documentation and should do more and more practice. One should learn the best practices to avoid inefficient coding.

Beware of using jQuery extensions

Although it’s a good idea to use jQuery in your project that doesn’t mean I am suggesting that you use every jQuery extension you can find to just throw the features together. For small projects, this can be a reasonable approach for a couple of features, but you must know that every jQuery extension you use in your code will potentially contribute to significant performance reductions. On the other hand, you must check the age of the extension if they are too old because in that case, they could be adding a lot of bloat for things like IE8 or even IE7 support.

In short make sure you are using jQuery extension to add some functionality, do some testing to see how much it slows down your website. If you are using code copy and paste from other sites like StackOverflow, make sure what it is doing before using it.

Use jQuery with other frameworks

I will suggest you use Vue.js as a framework because it’s being used by lots of people currently. It is the fastest-growing JavaScript framework in 2020. Vue is very easy to use, with simple naming conventions and a very low barrier to entry.

Using jQuery in conjunction with Vue doesn’t really add a lot of additional features, sure. But it can lead you to integrate functionality in a few minutes which could take you an hour to write in Vanilla JavaScript. You may also use jQuery with other frameworks like Angular, React, EmberJs, etc.

When to actually avoid jQuery

If you are familiar with jQuery it’s good to use it is in small or medium-scale projects from the budget point of view. But for large scale project complexity may arise due to adding a number of functionalities to it. If you are working in a team of multiple people on a website, jQuery can make more complications in your code and may lead to an unattainable spaghetti monster of a website. In this case, it is advisable to use more rigid frameworks, such as Vue or Angular, which provides more opinionated of a base to build from, instead of the free-for-all cage fight that is jQuery-based development.

jQuery is great and has lots of benefits. I still love using it daily, and it saves me a significant amount of time on my projects. However, you should be aware of any performance-related impact it is having on your website.

Leave a Reply