Skip to content

Instantly share code, notes, and snippets.

@jmas
Last active August 30, 2016 23:53
Show Gist options
  • Save jmas/c7c11f1431bf97f0333d6da639b0c0cd to your computer and use it in GitHub Desktop.
Save jmas/c7c11f1431bf97f0333d6da639b0c0cd to your computer and use it in GitHub Desktop.
DOM diff libraries test
// Uncomment only when you use it in test:
// import * as diffhtml from 'diffhtml';
// import morphdom from 'morphdom';
// You need a document with <div id="root"></div>
var rootEl = document.getElementById('root');
// Replace with big real HTML pice.
var tpl = `<div>Replace with real big HTML pice.</div>`;
console.profile("diffhtml.innerHTML()");
var start = window.performance.now();
for (var i=0,ln=1000; i<ln; i++) {
// You can uncomment one of 3 following tests:
// Test 1. Native innerHTML
// rootEl.innerHTML = tpl//tpl.replace(/\{rnd\}/ig, fn);
// Test 2. diffhtml.innerHTML
// diffhtml.innerHTML(rootEl, tpl);
// Test 3. morphdom
// morphdom(rootEl, tpl);
}
console.profileEnd();
console.log(window.performance.now() - start);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment