removeChildren (v3)

Revision 3 of this benchmark created by Mathias Bynens on


Description

From http://elv1s.ru/files/html+css/removeChildren.html

With an additional test for teh lulz

Preparation HTML

<script>
  var element = document.createElement('div');
  
  function prepareTest() {
   var i = 200,
       p, j, span;
   while (i--) {
    p = document.createElement('p');
    j = 5;
    while (j--) {
     span = document.createElement('span');
     span.appendChild(document.createTextNode(i * j + 'yada-yada'));
     p.appendChild(span);
    };
    element.appendChild(p);
   };
   document.body.appendChild(element);
  };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
innerHTML
prepareTest();

element.innerHTML = '';
ready
textContent
prepareTest();

element.textContent = '';
ready
removeFirstChild
prepareTest();

var child;
while (child = element.firstChild) {
 element.removeChild(child);
};
ready

Revisions

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

  • Revision 1: published by Nikita Vasilyev on
  • Revision 2: published by Thomas Aylott on
  • Revision 3: published by Mathias Bynens on
  • Revision 7: published on
  • Revision 8: published by Francis Avila on
  • Revision 9: published on