Frontend & browser·Storage and platform APIs
you needed to know when someone else's script changed the DOM, so you watched the subtree.
MutationObserver
Also calledmutation observer
An API reporting DOM changes asynchronously in batches, as microtasks after the current task. It is the tool for reacting to markup you do not control — third-party widgets, injected content, extensions. Observing a large subtree with all options enabled is expensive, and the callback runs before paint, so heavy work in it delays the frame.