Value vs Text vs innerHTML (v4)

Revision 4 of this benchmark created on


Description

Setting new text to input or textnode

Preparation HTML

<div id="text">1</div>
<input id="inpt" type="text" name="input" spellcheck="false" value="1">

Test runner

Ready to run.

Testing in
TestOps/sec
innerHTML
var i = 0,
    il = 150,
    place = document.getElementById("text");

for (i; i < il; i += 1) {
 var new = "text" + i;
 place.innerHTML = new;

}
ready
value
var i = 0,
    il = 150,
    place = document.getElementById("inpt");

for (i; i < il; i += 1) {
 var new = "text" + i;
 place.value = new;

}
ready
nodeValue
var i = 0,
    il = 150,
    place = document.getElementById("text");

for (i; i < il; i += 1) {
 var new = "text" + i;
 place.nodeValue = new;

}
ready

Revisions

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