JSFiddle - React, Tailwind, and code Playground

by Darby Rathbone

HTML

something
<div>something else</div>
<div>again</div>
<span>something else</span>

JavaScript

var target = window.document;
 
// create an observer instance
var observer = new MutationObserver(function(mutations) {
  mutations.forEach(function(mutation) {
    console.log(mutation);
  });    
});
// configuration of the observer:
var config = {characterDataOldValue:true,attributeOldValue:true,subtree:true, attributes: true, childList: true, characterData: true };
 
// pass in the target node, as well as the observer options
observer.observe(target, config);
console.log(document.childNodes.length);
[].slice.call(document.childNodes).map(function(e){document.removeChild(e);return e;}).forEach(function(e){document.appendChild(e);});