UI frameworks output size: how Svelte is even possible
I initially set out to write a deep dive into the source code and output code of React and Svelte. However, I realized that the post was becoming overly boring and lengthy, so here is a summary of the key takeaways I found out:
- Svelte is essentially a modern React with no virtual DOM and some compile-time optimizations
- Svelte 5 runes reduces compile-time magic: the framework now mostly transpiles component files into pure functions, renames stuff like
$effect
->user_effect
/template_effect
, and usesset
andget
for$state
- React, by contrast, only compiles JSX into JavaScript
- React’s larger size is likely due to its age and popularity. Virtual DOM doesn’t help either
- I couldn’t figure out how Svelte achieves its impressive compression rates