Replace text in node (v4)

Revision 4 of this benchmark created on


Preparation HTML

<div id="something">old text</div>

Test runner

Ready to run.

Testing in
TestOps/sec
innerHTML
document.getElementById("something").innerHTML = "new text";
ready
DOM traversing
var element = document.getElementById('something');

// removing everything inside the node
while (element.firstChild) {
    element.removeChild(element.firstChild);
}

// appending new text node
element.appendChild(document.createTextNode('new text'));
ready
textContent
document.getElementById('something').textContent = "new text";

ready

Revisions

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