When Svelte first captured the web development community, it arrived with a bold manifesto:
"Virtual DOM is pure overhead. Svelte runs at build time, converting your components into tiny, highly efficient vanilla JavaScript that surgically updates the DOM."
For five years, developers celebrated Svelte's compile-time reactivity. You did not need useState , dependency arrays, or reconciliation engines. You simply wrote ordinary JavaScript:
< script > let count = 0 ;
function increment () { count += 1 ; } < /script > < button on : click = { increment } > Clicks : { count } < /button >
Enter fullscreen mode
Exit fullscreen mode
Under the hood, Svelte 3 and 4 parsed your script, spotted the assignment operator ( count += 1 ), and injected a hidden compiler helper called $$invalidate :
function increment () { $ $invalidate ( 0 , count += 1 ); }
Enter fullscreen mode
Exit fullscreen mode
Whenever $$invalidate fired, Svelte flagged a bitmask dirty array on the component instance.…