JSFiddle - React, Tailwind, and code Playground

by dirtyd77

HTML

<div id="domnodes"></div>

JavaScript

MutationObserver = window.MutationObserver || window.WebKitMutationObserver;

var observer = new MutationObserver(function(mutations, observer) {
    // fired when a mutation occurs
    console.log(mutations, observer);
    // ...
});

// define what element should be observed by the observer
// and what types of mutations trigger the callback
observer.observe(document, {
  subtree: true,
  attributes: true,
  childList: true
});

var frag,
    i = 0,
    target = document.getElementById('domnodes');

console.time('time1');

frag = document.createDocumentFragment();

for (i; i < 100000; i++) {
  var p = document.createElement("p");
  p.textContent = 'p' + i;
  frag.appendChild(p);
}

target.appendChild(frag);

console.timeEnd('time1');

//target.innerHTML = '';