removeChildren

JavaScript performance comparison

Revision 7 of this test case created

Info

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

With an additional test for teh lulz

Preparation code

<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

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
innerHTML
prepareTest();

element.innerHTML = '';
pending…
textContent
prepareTest();

element.textContent = '';
pending…
removeFirstChild
prepareTest();

var child;
while (child = element.firstChild) {
 element.removeChild(child);
};
pending…
removeFirstChild no assign
prepareTest();

var child;
while (element.firstChild) {
 element.removeChild(element.firstChild);
};
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment