So is jQuery Too Big?
We’ve gone through all of the data, so now it’s time to return to the question. And like the answer to any software development question, the answer always depends on the specific situation. Let’s start by summarizing our numbers.
- Downloading jQuery 2.1.0, or 28.56KB takes
- 229ms to download on the worst mobile networks (1Mbsp).
- 46ms to download on average mobile networks (5Mbsp).
- 19ms to download on awesome mobile networks (12Mbsp).
- Downloading jQuery adds zero latency as long as you’re concatenating it with you app’s other scripts. If you’re not, expect an additional script to add roughly 150ms to 1 full second of load time to your application.
- Parsing/executing jQuery 2.1.0 takes
- ~15-20ms on desktop browsers
- a few hundred milliseconds on most mobile browsers
- possibly a full second or more on old devices.
The numbers that stand out the most are the parse times on older Android browsers. Having the potential to add a full second or more of load time to your application is a really bad thing.
There’s Almost Certainly Something Way More Important to the Efficiency of Your Application Than Whether You Use jQuery
According to the HTTP archive the average Web page now
- is over 1.7MB,
- makes over 90 HTTP requests,
- includes over 1MB of images,
- makes only 46% of its resources cacheable.
So before you care about jQuery, first make sure you
- minify your CSS/JS assets,
- concatenate your CSS/JS assets,
- gzip your HTML/CSS/JS assets,
- compress your images,
- set appropriate cache headers,
- remove unnecessary HTTP requests.
Often removing an image or two can improve your performance more than removing jQuery, and is far easier to do. If you have performed all these optimizations, and are still experiencing performance issues on mobile devices, then look into removing libraries like jQuery – just make sure you cover your bases first.