Why Frameworks Exist

With plain DOM code you write imperative updates: when a todo is added, create an <li>, append it, then find the button and change its label. Every feature adds another place that must update every affected element, and bugs appear when one is forgotten. Frameworks flip this around. You describe the interface declaratively as a function of state (view = f(state)), change the state, and the framework works out which DOM operations are needed.

Three ideas recur in every framework in this section:

Two ways a framework turns a state change into a DOM update
Two ways a framework turns a state change into a DOM update

Svelte 36,701 and Angular also compile templates into JavaScript that updates DOM nodes directly. A common interview question is "Is the virtual DOM fast?" Honest answer: fast enough and predictable, but it does work that signal-based frameworks skip.