The best you can do is use DOM mutation events. There are various events such as DOMNodeInserted
, DOMNodeRemoved
, DOMAttrModified
etc (see the DOM events spec, linked to above). There is a general catch-all event called DOMSubtreeModified
that is fired after any individual DOM mutation; this event bubbles, so you can set a listener on the document to be notified of all changes to the document's DOM.
document.addEventListener("DOMSubtreeModified", function(evt) {
console.log("DOM mutation", evt);
}, false);
These events are supported in most recent browsers, with the exception of IE (up to and including version 8).