v135 ยท dom
Deprecate Mutation Events
Mutation Events, including `DOMSubtreeModified`, `DOMNodeInserted`, `DOMNodeRemoved`, `DOMNodeRemovedFromDocument`, `DOMNodeInsertedIntoDocument`, and `DOMCharacterDataModified`, are quite bad for page performance, and also significantly increase the complexity of adding new features to the Web. These APIs were deprecated from the spec (https://w3c.github.io
concepts
-
Mutation Events vs MutationObserver
Run a 500-node insertion through both APIs at once and compare events fired, records seen, and total time spent in each handler.
-
Mutation-event linter for your code
The migration use case from the Intent to Remove: paste any JS, get a per-line audit of legacy event names and the recommended
MutationObserverreplacement. -
MutationObserver recipe book
Drop-in recipes for each deprecated event —
DOMNodeInserted,DOMNodeRemoved,DOMSubtreeModified,DOMAttrModified— with a sandbox you can mutate to watch the observer report records in real time. -
Migration Wizard
Select any deprecated Mutation Event and see the exact MutationObserver equivalent side-by-side. A live DOM sandbox lets you fire insert, remove, text, and attribute mutations and watch the replacement observer respond.
-
Performance benchmark
Run a configurable DOM insertion benchmark (100โ2000 nodes) comparing Mutation Events vs MutationObserver. The key insight: Mutation Events fire once per node synchronously; MutationObserver fires once per batch asynchronously. Bar charts, callback counts, and a live event log.
why it shipped
Mutation Events have been deprecated for over a decade, with the replacement (Mutation Observer) available also for over a decade. The fact that these events are still supported in browsers makes the addition of new features much more difficult, prohibitively so in some cases. For example, these feature requests and projects are all negatively impacted by the existence of Mutation Events: - iFrame reparenting: https://github.com/whatwg/html/issues/5484 and https://github.com/whatwg/dom/issues/891 - Child reordering: https://github.com/whatwg/dom/issues/586 - DOM Parts and batch DOM updates: