bi-04 — Broader Ideas

The cost model every framework is betting on

React's virtual DOM, Vue's dependency tracking, and signals are three different answers to "DOM mutation is expensive." This module is where you learn the actual cost structure, which is what lets you evaluate those bets rather than adopt them.

The correction most engineers need: DOM writes are cheap — they mark dirty. What is expensive is forcing synchronous recomputation, and building enormous trees. A model that says "the DOM is slow" cannot predict which of two loops is 100× worse.

Queued notification is a universal API design problem

Custom element reactions, MutationObserver, and the parser's construction site all queue rather than notify synchronously, for one reason: author code must never observe a half-built state.

You will design an API that notifies on change. The questions this module hands you:

  • Can a callback observe an intermediate state? (If yes, you have a bug class.)
  • Can a callback mutate the thing being iterated? (See fw-01's listener snapshot.)
  • Is the delivery batched, and on what boundary?
  • Is there a bounded-loop case like ResizeObserver, and what is the bound?

Lifetime beyond reachability

ActiveScriptWrappable — "keep me alive while I have pending activity" — appears in every system with in-flight work: connection pools, job queues, subscription managers, async iterators. And so does its guard: a teardown clause that releases everything when the owning context dies. A keep-alive without a matching teardown is a leak with extra steps.

Next

  • bi-05 explains why the wrapper exists and what crossing it costs.
  • bi-07 picks up invalidation, which is what a mutation actually schedules.
  • fw-02's DOM-operation counter measures the model this module describes.