Debounced Mutation Observer
This micro-library observes DOM changes on arbitrary element (including subtrees) with debounce built-in.
Usage
It's pretty much the same as the native MutationObserver.
For example,
import {DebouncedMutationObserver} from "debounced-mutation-observer";
const msToWait = 1000;
const observer = new DebouncedMutationObserver(callback, msToWait);
observer.observe(document.getElementById('target'));
// ...
observer.disconnect();
Demo
Download this repository, run the NPM build script, then open index.html
.