textContent vs createTextNode() vs innerHTML (v23)

Revision 23 of this benchmark created on


Preparation HTML

<div id="placehere"></div>
<script>var target = document.getElementById('placehere');</script>
<style>#placehere{display:none;}</style>

Setup

target.innerHTML = '';

Test runner

Ready to run.

Testing in
TestOps/sec
Target < Element .textContent
var el = document.createElement( 'p' );
el.textContent = "THIS IS A TEST";
target.appendChild( el );
ready
Target < Element < TextNode(Text)
var el = document.createElement( 'p' );
var tn = document.createTextNode('THIS IS A TEST');
el.appendChild( tn );
target.appendChild( el );
ready
innerHTML (for cheaters)
target.innerHTML = '<p>THIS IS A TEST</p>';
 
ready

Revisions

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