JavaScript erkennen, wann sich die Anzahl der Elemente ändern

const targetNode = document.body;
const config = { childList: true, subtree: true };

const callback = function(mutationsList, observer) {
    for(let mutation of mutationsList) {
        if (mutation.type === 'childList') {
            // Elements have changed
        }
    }
};

const observer = new MutationObserver(callback);
observer.observe(targetNode, config);
TC5550