cloneNode vs innerHTML

Benchmark created on


Preparation HTML

<!doctype html>
<title> yodle </title>
<body>
<div id=lediv>
</div>
</body>

Setup

var lediv = document.getElementById('lediv');
    var marker = document.createElement('div');
    marker.textContent = '%N%';
    var text = marker.outerHTML;

Test runner

Ready to run.

Testing in
TestOps/sec
cloneNode
var node = marker.cloneNode();
node.textContent = node.textContent.replace('%N%', 3);
lediv.appendChild(node);
ready
innerHTML
var html = text.replace('%N%', 3);
lediv.innerHTML = html;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.