Skip to content

The Three Pillars of JavaScript Bloat and the Fixes

JavaScript bloat comes from dependency sprawl, polyfill debt, and framework overhead. Learn how to measure each pillar and cut the bytes nobody needs.

· · 10 min read

Updated: November 23, 2026

Table of runtime size and hydration approach for React, Vue, Svelte, Astro islands and Qwik

JavaScript bloat is the accumulation of unnecessary bytes in a production bundle, code that ships to the browser but never executes or never needed to exist for that user's device, and it almost always traces back to three separable causes rather than one. The usual story: a homepage ships far more JavaScript than anyone intended, and the team has no idea it got that bad because the growth happened slowly, one reasonable feature at a time.

Bloat is three separate problems that get reported as one number. The "three pillars" framing comes from James Garbutt's The Three Pillars of JavaScript Bloat, whose pillars sit in the npm ecosystem: support for very old engines, atomic single-purpose packages, and ponyfills that outlived their need. This guide borrows the name and cuts the problem from the application side instead, because each of these three requires a different diagnosis and a different fix. Ignore any single pillar and your bundle stays fat no matter how much you optimize the other two.

Pillar one: dependency sprawl

The HTTP Archive's 2025 Web Almanac found the median desktop page ships 708 KB of compressed JavaScript, and the median mobile page 646 KB. Mobile gets roughly the same payload on connections that are far slower. Most of it comes from packages you didn't realize you installed.

Run npm ls --all in any mid-size project and you'll see hundreds of transitive dependencies. Each direct dependency pulls in its own tree, and a short package.json can resolve to a very long lockfile.

A typical sequence: a developer needs date formatting and installs moment.js. For 2.30.1, Bundlephobia reports about 301 KB minified and 77 KB gzipped. Bundle it with esbuild on bundlejs and the same version comes out near 20 KB gzipped, and so does the current 2.31.0. My read is that the gap is the locale files, since webpack's own docs note that since moment 2.18 all locales get bundled together with the core library unless you exclude them with IgnorePlugin. Another dev needs a color picker and pulls in a package with its own dependency tree. Nobody checks the cost, because the install takes two seconds and nothing complains.

The fix starts with visibility. Run npx source-map-explorer build/static/js/*.js after a production build and you'll see exactly which packages eat the most space. Swap moment.js for date-fns (tree-shakeable, you only import what you use). Replace lodash with lodash-es or just write the three utility functions you actually need. I'd rather own three small functions than carry a utility belt for them.

Bundlephobia.com should be a mandatory check before every npm install. It shows minified size, gzipped size, download time on 3G, and whether the package supports tree-shaking. Treat it like a code review gate.

Pillar two: polyfill debt

Shipping transpiled and polyfilled code for browsers that represent under 0.5% of your traffic is one of the larger sources of unnecessary bytes. This is polyfill debt, code your users' browsers don't need. Philip Walton measured one real bundle both ways and found the legacy ES5 build more than twice the size of the ES2015+ build, even gzipped.

Babel's @babel/preset-env with useBuiltIns: 'usage' was supposed to fix this. It helps. But many projects still target IE 11 in their browserslist config even though Microsoft ended support for the IE 11 desktop app on Windows 10 on June 15, 2022. That single line forces Babel to polyfill Promises, Array.from, Object.assign, Symbol, and dozens of other features that every modern browser has supported for years.

Check your .browserslistrc right now. If it says > 0.5%, last 2 versions, not dead, you're probably fine. If it includes ie 11 or chrome 49, you're shipping polyfill code to nearly everyone, and nearly everyone doesn't need it.

Tightening the target from > 1% to > 0.5%, not dead is free performance when your old config was stricter than your real audience. Nothing about the features changes; you delete code nobody needed. Before and after:

{
  "browserslist": ["> 1%"]
}
{
  "browserslist": ["> 0.5%", "not dead", "not ie 11"]
}

Does your team even know which browsers you officially support? If nobody can answer, that's the root cause.

Pillar three: framework overhead

This is the one people argue about. Frameworks ship runtime code that executes before your application logic even starts. Bundle react plus react-dom/client with esbuild on bundlejs and React 19.3.1 comes out at about 69 KB gzipped, against about 46 KB for React 18.3.1 with the same query. Vue's runtime build (the package's default vue.runtime.esm-bundler.js entry) measures about 51 KB for 3.5.45 and about 42 KB for 3.4.38. Those are whole-entry numbers before your own bundler drops unused exports, so treat them as ceilings. Svelte is the odd one out: it's a framework that uses a compiler, so what ships depends on which features your components use rather than on a fixed runtime figure.

That React 19 number matters because it's the baseline every page downloads before any of your own code. The React Compiler doesn't shrink it either: per the React docs it's a build-time tool that adds memoization to your components so you can stop hand-writing useMemo and useCallback, not a lighter runtime. Paying that baseline is a fair trade for a large interactive app doing lots of re-renders. It's a bad trade for a content site that just needs one accordion to open and close.

I think most SPAs don't justify their framework cost, and I'd say the same about plenty of sites I've seen built on React by default. Good luck telling that to a team that's already committed to React 19.

Hydration costs more than the download does. The server sends HTML, then the browser downloads JavaScript, parses it, and re-executes component logic to attach event handlers. All of that runs on the main thread the user's taps also need, so on a low-end phone a complex page can look ready a noticeable while before it actually responds.

Newer patterns help. React Server Components reduce client JavaScript. Astro's islands architecture ships zero JS by default and only hydrates interactive components. Qwik takes a radical approach with resumability, no hydration at all. None of them is free to adopt, but each one goes after the framework pillar directly.

Framework runtime costs compared

Framework runtime is the code that ships before you write a single line of your own, and the spread across popular choices is wider than most teams assume. React 19.3.1 costs roughly 69 KB minified and gzipped once you count react plus react-dom/client, measured with esbuild on bundlejs. Svelte has no comparable single number, because its compiler does the framework's work at build time and what's left depends on the features a component uses. The number to weigh any of this against is your total bundle: 69 KB inside a 400 KB app is noise, while the same 69 KB inside a 90 KB marketing site is most of your budget. Hydration approach matters just as much as size, since re-executing your whole component tree on the client costs main-thread time no gzip setting will recover.

FrameworkProduction runtime sizeHydration approach
React 19.3.1 (react + react-dom/client)~69 KB gzipped (bundlejs, esbuild)Full client re-execution to attach handlers
Vue 3.5.45 (runtime build)~51 KB gzipped, whole entry (bundlejs, esbuild)Similar hydration model to React
SvelteDepends on features usedA compiler does the framework's work at build time
Astro islands0 JS by defaultOnly hydrates interactive components
QwikMinimalResumability, no hydration step at all

Measuring all three in one audit

The checklist I'd run is below, and its order is deliberate. Dependency sprawl comes first because it's where the biggest single wins hide, one date library swapped for a lighter alternative can beat a week of careful code-splitting. Polyfills come second since they're usually a one-line config change once you know your real browser support floor. Framework overhead comes last because it's the only item on the list that might mean rewriting something, and you should never reach that conversation before the cheap fixes are done. Run all 3 checks in one sitting rather than spreading them across sprints, because the numbers only make sense relative to each other, and a chunk that looks alarming in isolation often turns out to be 4% of the total.

  1. Run a bundle analyzer to find the three largest non-application chunks
  2. Check Chrome DevTools Coverage tab for unexecuted (polyfill or dead) code
  3. Compare your framework's runtime size on bundlephobia.com against total bundle size
  4. Prioritize fixes by size, dependency sprawl first, then polyfills, then framework overhead

Bundle analysis

Run npx webpack-bundle-analyzer stats.json or npx vite-bundle-visualizer depending on your build tool. Look for the three biggest non-application chunks. Those are your dependency sprawl candidates. A one-off analysis only helps until the next dependency bump, so pin the numbers you get here in CI with a size budget, as shown in how size-limit catches bundle regressions.

Polyfill check

Open Chrome DevTools, go to the Coverage tab, and load your page. Red bars mean unexecuted code. If 40% of your main bundle is red, you've got polyfill debt or dead code or both.

Framework cost

Check your framework's runtime size on bundlephobia.com. Compare it against your total bundle. If the framework runtime is more than 30% of your JavaScript, you might be over-framed for the job. A blog doesn't need what a SaaS dashboard needs.

Cuts that pay off

Your split between the three pillars will differ from anyone else's, which is why the audit comes first. I'd expect dependency sprawl to dominate in an app with a long package.json and framework overhead to dominate on a small content site, but that's a guess until your analyzer says otherwise.

Start with the biggest pillar first. Swap heavy packages for lighter alternatives, moment for date-fns or the native Intl API is still the highest-yield trade I know of, since moment can cost up to about 77 KB gzipped once its locales ride along. Update your browserslist, and be honest about the floor rather than copying a config from 2019. Consider whether partial hydration or server components could reduce your framework footprint. And check what each remaining package is actually there for: a JavaScript scroll library that CSS now replaces outright is dependency sprawl and framework overhead billed twice for a progress bar.

My opinion is that most JavaScript bloat is a habit problem more than a technical one. Teams add dependencies without checking costs, never update their browser targets, and pick frameworks based on hiring rather than fit. No bundler setting fixes that.

  • Frontend ideas that keep returning - bloat runs on a cycle, and the same ideas return under new names once the pendulum swings
  • Node.js 20 to 24 migration - upgrading Node.js removes built-in polyfills and changes which globals exist; major version bumps directly affect your polyfill debt pillar
  • React 19: Complete Guide to New Features and Migration - the React Compiler automates memoization at build time; it changes render work, not the size of the React runtime
  • Lucide React - 1500+ SVG icons at ~1kB per icon via tree-shaking; the right way to add icons without dragging in a 200kB icon font

Frequently Asked Questions

How do I measure JavaScript bloat on my site?
Run Lighthouse in Chrome DevTools or use bundlephobia.com for individual packages. For full audits, webpack-bundle-analyzer or source-map-explorer will visualize exactly which modules consume the most bytes in your production bundle.
What is an acceptable JavaScript bundle size?
Alex Russell's performance budget suggests under 150 KB of compressed JavaScript for a good mobile experience on median devices. The median desktop page ships about 708 KB of compressed JavaScript (646 KB on mobile) per the 2025 Web Almanac, more than four times that budget.
What is the fastest way to reduce JavaScript bundle size?
Start with bundle analysis to find the biggest offenders. Replace heavy libraries with lighter alternatives, like date-fns instead of moment.js. Then enable tree-shaking, remove unused polyfills, and consider lazy loading routes that users don't hit on first page load.
Does tree-shaking automatically remove all unused code?
Tree-shaking removes unused exports only from ES modules with side-effect-free code. CommonJS modules (require/module.exports) don't tree-shake. Libraries without a sideEffects: false field in package.json may still ship unused code. Verify in bundle analyzer after enabling tree-shaking, some imports that look unused still carry side effects and won't be removed.
What are the most common causes of excessive JavaScript load time?
The three main causes are large vendor bundles (importing entire libraries instead of specific functions), render-blocking third-party scripts (analytics, chat widgets, A/B testing), and missing code splitting (all routes bundled into one file). A fourth issue is polyfills shipped to modern browsers that don't need them, use @babel/preset-env with browserslist targets to avoid this.