Performance: Why Svelte exists
HIGH IMPACT
Svelte affects page load speed and runtime rendering by compiling components to minimal JavaScript that updates the DOM directly.
<script> let count = 0; function increment() { count += 1; } </script> <button on:click={increment}>{count}</button>
import React from 'react'; function App() { const [count, setCount] = React.useState(0); return <button onClick={() => setCount(count + 1)}>{count}</button>; } export default App;
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| React Virtual DOM | Multiple nodes updated via diffing | Multiple reflows per update | Moderate paint cost | [X] Bad |
| Svelte Compiled DOM Updates | Direct node updates | Single reflow per update | Lower paint cost | [OK] Good |