jQuery and Why It May Be The Wrong Choice

jQuery and Why It May Be The Wrong Choice

jQuery is the most popular JavaScript library, so it may come as a surprise to some developers that it might not be the correct choice, and in many cases – it’s just not necessary. You could even say overkill. This graph demonstrates just how widely it is used.

jQuery graph

With the popularity of the web on mobile (as of 2014 it surpassed desktop browsing) you could see why it has become essential for a developer to also work on developing a mobile friendly and responsive site. With mobile devices generally having much slower internet than a typical desktop, a developer has to be conscious of load times.

jQuery isn’t the largest JavaScript library, although it is still quite a sizeable 249Kb (82Kb minified) and there are a lot of useful features packed into it. As a result of which, there will be a lot of the library that you won’t end up using. You can see the ever expanding list here. Therefore, jQuery as a library impacts mobile users quite significantly as it has to build objects for elements and load the library itself, on a 3G connection this doesn’t sound too appealing.

Some features and outputs using jQuery can also be achieved, in most cases, just as easily using vanilla JavaScript. A great website which exhibits this is here. On this site, you can input functions and it presents an alternative method using vanilla JavaScript. Which is a logical solution as jQuery just runs vanilla JavaScript anyway.

An example of adding a class jQuery:


An example of adding a class in Vanilla JavaScript:

if (el.classList)
    el.className += ' ' + className;

Do you need to stop using jQuery?

Despite the title of this post, we are not insinuating that jQuery is always the wrong choice, as it can be a good option for certain projects; it just shouldn’t be selected every time without evaluating other options. This post was written to help encourage developers to make the correct choice of their tools and methods for themselves by understanding that no library is always the best library.

Useful links


Andrew Collins