.innerHTML vs textContent vs value

JavaScript performance comparison

Test case created by Rob W

Preparation code

<div id="innerHTML"></div>
<div id="textContent"></div>
<input type="text" size="30" id="value" />

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
innerHTML
document.getElementById("innerHTML").innerHTML = 123456789;
pending…
textContent
document.getElementById("textContent").textContent = 123456789;
pending…
value
document.getElementById("value").value = 123456879;
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

1 comment

Best Man commented :

Value is the best for older browsers.

Add a comment