MutationObserverBaseline · Widely available
The MutationObserver API watches for changes to the DOM tree and calls a callback function when DOM changes occur.
Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Jul 29, 2015. Widely available since Jan 29, 2018.
Browser support
DesktopChrome
1–25Not supported
26+Supportedsince Mar 26, 2013
Current: 155Edge
12+Supportedsince Jul 29, 2015
Current: 154Firefox
1–13Not supported
14+Supportedsince Jul 17, 2012
Current: 157Safari
1–6Not supported
7+Supportedsince Oct 22, 2013
Current: 27MobileChrome Android
18–25Not supported
26+Supportedsince Apr 3, 2013
Current: 155Firefox Android
4–10Not supported
14+Supportedsince Jun 26, 2012
Current: 157Safari iOS
1–6Not supported
7+Supportedsince Sep 18, 2013
Current: 27How to use
This feature is Baseline widely available — use it freely, no fallback needed.
Example
JS
const observer = new MutationObserver((mutations) => {
for (const m of mutations) console.log(m.type, m.addedNodes);
});
observer.observe(document.body, { childList: true, subtree: true });
// later: observer.disconnect();Feature detection
JS · check before using
if ("MutationObserver" in globalThis) {
// MutationObserver is available
} else {
// load a polyfill or use a fallback
}Sub-features
Support for each part of the feature (15). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| MutationObserver | 26 | 12 | 14 | 7 | 26 | 14 | 7 |
| MutationObserver.MutationObserver | 26 | 12 | 14 | 7 | 26 | 14 | 7 |
| MutationObserver.disconnect | 26 | 12 | 14 | 7 | 26 | 14 | 7 |
| MutationObserver.observe | 26 | 12 | 14 | 7 | 26 | 14 | 7 |
| MutationObserver.takeRecords | 26 | 12 | 14 | 7 | 26 | 14 | 7 |
| MutationRecord | 16 | 12 | 14 | 7 | 18 | 14 | 7 |
| MutationRecord.addedNodes | 16 | 12 | 14 | 7 | 18 | 14 | 7 |
| MutationRecord.attributeName | 16 | 12 | 14 | 7 | 18 | 14 | 7 |
| MutationRecord.attributeNamespace | 16 | 12 | 14 | 7 | 18 | 14 | 7 |
| MutationRecord.nextSibling | 16 | 12 | 14 | 7 | 18 | 14 | 7 |
| MutationRecord.oldValue | 16 | 12 | 14 | 7 | 18 | 14 | 7 |
| MutationRecord.previousSibling | 16 | 12 | 14 | 7 | 18 | 14 | 7 |
| MutationRecord.removedNodes | 16 | 12 | 14 | 7 | 18 | 14 | 7 |
| MutationRecord.target | 16 | 12 | 14 | 7 | 18 | 14 | 7 |
| MutationRecord.type | 16 | 12 | 14 | 7 | 18 | 14 | 7 |