6 Lightweight jQuery Alternatives

The Javascript library jQuery has grown a lot over time and even the .min.js version is now almost 100 KB in size. However many of jQuerys functions are often not used at all. In addition to the download size, rendering time is a factor which can slow down the page loading on old smartphones. Considering those factors it might be worth looking for lighter alternatives. The basic functions that define jQuery however should still be available in the alternative libraries we’re looking at.

I compared some of the most frequently mentioned jQuery alternatives. The selection of features that were compared is purely subjective and based on the functions that I often use personally. For the GZIP compression the highest compression rate (gzip -9) was used. So the actual size in the browser may differ. The functions in the table below are named after the original jQuery functions and may be called differently in some of the frameworks.

Feature Comparison

jQuery 1.12.0 jQuery 2.2.0 Zepto 1.1.6 Sprint.js Minified.js 1.1 (Web) Cash 1.0.0 Umbrella JS 1.1.3 ki.js
Size (Minified) 97 KB 86 KB 25 KB 17 KB 10 KB 8 KB 5 KB 602 Byte
Size (GZIP) 34 KB 30 KB 9 KB 5 KB 4 KB 3 KB 2 KB 404 Byte
Ready-Function Yes Yes Yes Yes Yes Yes No Yes
each() (Array) Yes Yes Yes Yes Yes Yes No No
Ajax Yes Yes Yes No Yes No Yes No
ID-Selector Yes Yes Yes Yes Yes Yes Yes Yes
Class-Selector Yes Yes Yes Yes Yes Yes Yes Yes
.on()-Events Yes Yes Yes Yes Yes Yes Yes Yes
hide()/show() Yes Yes Yes No Yes No No No
append()/html() Yes Yes Yes Yes Yes Yes Yes No

File Size Comparison

Here is a graph that shows the different sizes of the libraries. Notably here is ki.js, which is less than 1 KB in size and thus over 100 times smaller than jQuery:

jQuery Alternatives File Sizes

Abstinence

For websites that don’t use much Javascript, it’s possible to not use libraries like jQuery at all by using the good old native functions instead. You might have a look at youmightnotneedjquery.com for that. The site shows the corresponding native functions for many of the jQuery functions.

Comments