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
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
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.