Bundle math: how much JavaScript you actually need
The 170 KB budget is a number someone tweeted in 2016. Your real number depends on your audience’s devices, their network, and how much of the page arrives as HTML.
There is no universal JavaScript budget, and the one everybody quotes was reverse-engineered from a mid-range phone on a 3G connection nine years ago. It was a good number then. It is a starting point now.
Work out your own number
Take the slowest device in the top 80% of your analytics, take the median connection for your largest market, and decide how long you are willing to make those people wait before the page responds to a tap.
| Audience | Device floor | Realistic budget | Read |
|---|---|---|---|
| Internal tool, corporate laptops | 2021 laptop | 600 KB | Cheap |
| Consumer site, mixed mobile | 2019 mid-range Android | 180 KB | Watch it |
| Global reach, emerging markets | 2017 low-end Android | 90 KB | Expensive |
Every kilobyte of JavaScript is a promise that the main thread will be busy at exactly the moment somebody tries to tap something.
Priya Raman, accessibility specialist
Then defend it in CI
A budget nobody enforces is a wish. Put the number in a file, fail the build when a pull request crosses it, and let the conversation happen on the pull request rather than in the retro.