innerText vs textContent (v5)

Revision 5 of this benchmark created on


Preparation HTML

<table>
 <tr>
  <td>empty</td>
  <td>empty</td>
  <td>empty</td>
  <td>empty</td>
  <td>empty</td>
 </tr>
</table>
<div class="grid">
 <div>
  <div>1</div>
  <div>1</div>
  <div>1</div>
  <div>1</div>
  <div>1</div>
 </div>
</div>

Setup

var table = document.querySelector('table'), x, y, rows, grid = document.querySelector('.grid');

Test runner

Ready to run.

Testing in
TestOps/sec
innerText
for (x = 0; x < 1; x ++) {
    rows = table.rows[x].cells;
    for (y = 0; y < 5; y ++) {
        rows[y].innerText = 'innerText';
    };
};
ready
textNode
for (x = 0; x < 1; x ++) {
    rows = grid.firstChild;
    while(rows) {
        rows.nextElementSibling.innerText = 'textNode';  
    };
};
ready

Revisions

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