textContent vs createTextNode() vs innerHTML (v30)

Revision 30 of this benchmark created by Karl Seamon on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div id="div"></div>

Setup

var div = document.getElementById('div');
    var jDiv = $(div);

Teardown


    document.getElementById('div').innerHTML = '';
  

Test runner

Ready to run.

Testing in
TestOps/sec
innerText
div.innerText = '1234';
div.innerText = 'abc';
ready
innerHTML
div.innerHTML = '1234';
div.innerHTML = 'abc';
ready
textContent
div.textContent = '1234';
div.textContent = 'abc';
ready
jQuery.text
jDiv.text('1234');
jDiv.text('abc');
ready

Revisions

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