Get started with MutationObserver.js CDN
WTFPL licensed
Library, MutationObserver.js: Real-time DOM structure change monitoring and reaction.
Tags:- DOM
- observer
- mutation observer
- MutationObserver
Stable version
Copied!
How to start using MutationObserver.js CDN
// Include the MutationObserver library from the CDN
const MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
// Create a new observer instance
const observer = new MutationObserver((mutationsList, observer) => {
// Your callback logic here
const targetElement = document.querySelector('#target');
if (targetElement) {
console.log('Element modified:', targetElement.innerHTML);
}
});
// Configuration of the observer
const config = { attributes: true, childList: false, subtree: false };
// Pass in the target node and configuration to the observer
observer.observe(document.body, config);
// Remove the observer when done
// observer.disconnect();
Copied!
Copied!