JavaScript bloat has become one of the most avoidable problems on the web.
Sites ship far more code than they need, and users pay the price. Slower loads, sluggish interactions and higher abandonment.
This is not an argument against JavaScript. It is an argument for using it deliberately. Too many sites depend on heavy frameworks, layers of dependencies and third-party scripts solving problems nobody actually has, and the result is a site that works well enough on the machine it was built on.
How JavaScript bloat accumulates
Nobody decides to ship a megabyte of script. It arrives in reasonable increments.
A framework chosen at the start, when the project might have needed it. A date library for one date. A carousel dependency for a carousel nobody swipes past the first slide of. Polyfills for browsers that stopped mattering years ago. A utility library providing three functions the platform now provides natively.
Then marketing adds a tag. Then another team adds analytics without checking whether analytics already existed. Two years later the bundle is what it is, and nobody can say why.
What JavaScript bloat costs
More than its file size suggests, which is the part that surprises people.
A hundred kilobytes of image is downloaded and decoded. A hundred kilobytes of JavaScript is downloaded, parsed, compiled and executed, and every one of those steps occupies the browser’s main thread.
While that thread is busy, taps go unanswered. The visitor presses again, and now the form has submitted twice or the menu has opened and closed. That is measured as Interaction to Next Paint, and it is the failure people read as the site being broken rather than slow.
On a mid-range phone the execution takes considerably longer than on a development laptop, which is why this problem reliably survives testing.
Finding your JavaScript bloat
Open your busiest page in a browser network panel with the cache disabled, and filter to scripts. Note the total and the largest individual files.
Then run the coverage tool in the same panel, which reports how much of each script actually executes on that page. The proportion of unused code is usually higher than anyone expects, and seeing the number is what makes the case internally.
Record the conditions so later measurements are comparable: device, connection, first or repeat visit.
Reducing JavaScript bloat
- Audit dependencies. For each one, ask what problem it solves and whether the platform now solves it. A surprising number answer questions browsers answered years ago.
- Prefer the platform. Semantic HTML provides keyboard operation and assistive technology support with no script at all. CSS handles transitions, layout, sticky positioning and container queries natively, in optimised code paths rather than in your bundle.
- Split and defer. Load what this page needs now and the rest when needed. A checkout script has no business running on a blog post.
- Audit third parties hard. List every external domain and find an owner. Unclaimed ones cost nothing to remove and frequently cause the responsiveness problem rather than your own code.
- Remove rather than optimise. Minifying code you should have deleted is effort in the wrong place.
The accessibility connection
Fewer custom components usually means better accessibility, because native elements arrive with keyboard support and correct semantics built in. A `<button>` is focusable and announced properly. A styled `<div>` is neither until somebody rebuilds both, usually incompletely.
That is a genuine overlap rather than a causal relationship. Work towards WCAG 2.1 Level AA on its own terms and treat the lighter bundle as a useful consequence.
Keeping JavaScript bloat down
Set a bundle size budget enforced in your build process, so a deployment fails when the ceiling is exceeded.
Dependencies accumulate through ordinary development rather than through anybody’s poor judgement, and manual review depends on somebody remembering, which stops happening within months.
Where performance and environmental impact both apply, treat them as the same lever: reducing unnecessary data transfer and processing supports a faster experience while lowering estimated digital carbon, though environmental figures remain modelled rather than directly measured.
Our sustainable web development work includes coverage analysis, which is usually where the largest unused payload turns up.

