textContent vs createTextNode() vs innerHTML (v4)

Revision 4 of this benchmark created on


Preparation HTML

<div id="div">asdfghkkl</div>

Setup

var div = document.createElement( 'div' );

Test runner

Ready to run.

Testing in
TestOps/sec
textContent
var i = 10;
while (--i) div.textContent += '1234'+i;
 
ready
createTextNode()
var i = 10;
while (--i) div.appendChild( document.createTextNode( '1234'+i ) );
ready
innerHTML
var i = 10;
while (--i) div.innerHTML += '1234'+i;
 
ready

Revisions

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