Go to the home page logo

UI frameworks output size: how is Svelte even possible?

I tested React, Vue, Angular and Svelte by the output size they produce when running their build commands, using the tools recommended in their documentation for single-page applications:

  • React 18.3 with Vite
  • Vue 3.5 with create-vue
  • Angular 19.0 with Angular CLI (ng) (routing disabled)
  • Svelte 5.15 with Vite (runes mode)

For each framework, I tested with 1, 2, 5, 10, 20, 50, and 100 instances of the following component types:

  1. Static component: A simple “Hello, World!”
  2. Dynamic component: A counter
  3. To-do list: A single-component to-do list
  4. Multi-component to-do list: A to-do list split into multiple components

Code setup

To automate these tests, I created some helper functions

Copy files

import { readFile, unlink, writeFile } from "fs/promises";

async function copyFiles(path: string, name: string, repeat: number) {
  const origin = await readFile(path, { encoding: "utf-8" });

  await unlink(path);

  for (let i = 1; i <= repeat; i++) {
    const updated = origin.replaceAll(name, `${name}${i}`);
    const updatedPath = path.replace(name, `${name}${i}`);

    await writeFile(updatedPath, updated, { encoding: "utf-8" });
  }
}

// copyFiles("./react-counter/src/Counter1.tsx", "Counter", 100);

Generate components and imports

function generateImports(name: string, repeat: number) {
  for (let i = 1; i <= repeat; i++) {
    console.log(`import ${name}${i} from "./${name}${i}"`);
  }
}

function generateComponents(name: string, repeat: number) {
  for (let i = 1; i <= repeat; i++) {
    console.log(`<${name}${i} />`);
  }
}

function generateAngularComponentImports(name: string, repeat: number) {
  for (let i = 1; i <= repeat; i++) {
    console.log(`${name}${i},`);
  }
}

// generateImports("Counter", 100);
// generateComponents("Counter", 100);

Results

Type/FrameworkReactVueAngularSvelteSvelte gzip
Static 1144 kB58.5 kB128.5 kB9.8 kB
2144 kB58.6 kB128.7 kB10.2 kB
5144 kB58.9 kB129.4 kB10.4 kB
10144 kB59.4 kB130.6 kB10.9 kB
20145 kB60.4 kB132.9 kB11.8 kB
50147 kB63.4 kB139.8 kB14.5 kB
100151 kB68.3 kB151.4 kB19.1 kB
Dynamic 1144 kB59.4 kB131.9 kB11.8 kB
2144 kB59.5 kB132.3 kB12.0 kB
5144 kB60 kB133.4 kB12.7 kB
10145 kB60.9 kB135.4 kB13.7 kB
20147 kB62.6 kB139.2 kB15.7 kB
50152 kB67.6 kB150.8 kB21.9 kB
100161 kB76 kB170 kB32.1 kB
To-do single component 1145 kB61.6 kB145.2 kB19.5 kB9.1 kB
2146 kB62.9 kB146.9 kB20.8 kB9.2 kB
5149 kB66.8 kB152.2 kB24.3 kB9.3 kB
10155 kB73.1 kB160.9 kB30.2 kB9.6 kB
20166 kB85.9 kB178.3 kB42.0 kB10.1 kB
50200 kB124 kB230.6 kB77.2 kB11.6 kB
100257 kB187 kB317.8 kB136 kB13.9 kB
To-do multiple components 1145 kB62.1 kB147.4 kB20.1 kB9.3 kB
2146 kB63.9 kB150.4 kB21.9 kB9.4 kB
5151 kB69.2 kB159.4 kB26.9 kB9.7 kB
10158 kB77.9 kB174.2 kB35.3 kB10.2 kB
20172 kB95.4 kB204 kB52 kB11.1 kB
50215 kB148 kB293 kB102 kB13.6 kB
100286 kB235 kB441.5 kB186 kB17.6 kB
+ React Memoization/Svelte snippets 1145 kB--19.7 kB9.1 kB
2146 kB--21.1 kB9.3 kB
5151 kB--25.1 kB9.5 kB
10158 kB--31.8 kB9.8 kB
20173 kB--45.1 kB10.5 kB
50217 kB--85.1 kB12.4 kB
100290 kB--152 kB15.4 kB

Conclusion

Well, Svelte is the star of this comparison!

Not only does Svelte produce significantly smaller build sizes compared to other frameworks, but its output also compressed exceptionally well with gzip. While gzip typically reduced file sizes by ~5x for other frameworks, Svelte’s output was reduced by ~10x (initially, I chose not to include gzipped results because I assumed compression ratios would be similar across frameworks)

Shifting much of the framework’s complexity to build time seems like a working strategy.

If your priority is a minimal bundle size while retaining the developer experience of a modern UI framework, Svelte is an obvious choice.

However, the lack of popular production-ready client-side routing solution is a concern for me. I prefer not to spin up a server with SvelteKit just for a few interactive pages, so I’d stick with other frameworks for now.

Developer experience

From a developer experience perspective, all frameworks were pleasant to use. Personally:

  • I find Angular’s and Vue’s templating languages less intuitive.
  • Angular’s separation of component and class names feels odd.

But this comes down to personal preference. All these frameworks - React, Vue, Angular, and Svelte - are excellent tools


Stay tuned for the second part of this blog post where I’ll dive deeper into what some of these frameworks produce (I’m specifically interested in Svelte and React). I plan to explore the actual files and functions they generate, examining the unminified code