Oriel — AI & technology worth noticing, every day.

Svelte 5 Isn't Pure Compiler Magic: How Runes, Fine-Grained Signals, and Direct DOM Mutations Actually Work Under the Hood

Post · https://dev.to/smtahosin/svelte-5-isnt-pure-compiler-magic-how-runes-fine-grained-signals-and-direct-dom-mutations-36a3

A visual, 10-minute deep dive into Svelte 5 internals. Learn why Svelte shifted from compile-time dirty checking to runtime signals, how the Push-Pull reactive dependency graph works, how the compiler compiles templates into direct DOM operations without a Virtual DOM, and when to use $state.raw for maximum performance.

First seen by Oriel on .

AI summary

The article explains how Svelte 5 combines compiler-generated static templates with runtime signals to update specific DOM nodes, and how Runes change reactivity, state management, and performance trade-offs.

  • $state, $derived, and $effect form a runtime dependency graph: writes mark dependents dirty, while derived values are recomputed lazily when read.
  • The compiler hoists static markup into templates and attaches effects to dynamic slots, so updates can mutate targeted text nodes without virtual DOM diffing.
  • Deep $state proxies enable nested mutation tracking, while $state.raw avoids proxying large or externally managed objects but requires root-reference replacement for updates.
  • The article recommends $derived for values computed from state and reserving $effect for external side effects, avoiding redundant synchronization and extra render cycles.
  • The text contrasts this model with Svelte 4's component-level dirty checking and store boilerplate; its final section on .svelte.js modules is cut off.

#svelte #javascript #reactivity #web performance

Generated by gpt-5.6-sol. Check the original for details.

Metric trends

Last 30 days · Up to 120 recorded samples per source and metric, with reposts kept separate · First and latest retained

Reactions

Total public reactions reported by the source; distinct from points and likes.

  • DEV Community: 19, latest observation ; +4 over observed period since

Comments

Comment count reported by the source.

  • DEV Community: 4, latest observation ; 0 over observed period since

Aliases

SourceExternal IDURL
DEV Community4828068https://dev.to/smtahosin/svelte-5-isnt-pure-compiler-magic-how-runes-fine-grained-signals-and-direct-dom-mutations-36a3 Read discussion