innerHTML vs removeChild (v17)

Revision 17 of this benchmark created by Grant Kiely on


Preparation HTML

<div id='box'></div>

Setup

var box = document.getElementById('box');
  box.innerHTML = '<h1>this is a heading<h1><div id="wrapper">Here is some cmmon content that you might find in a website</div><p>qesdafsdafdsa<p>testasingsda<p>tesa</p><h4>here is some more content<h4><h3>asdf</h3><div>more content</div><h1>this is a heading<h1><div id="wrapper">Here is some cmmon content that you might find in a website</div><p>qesdafsdafdsa<p>testasingsda<p>tesa</p><h4>here is some more content<h4><h3>asdf</h3><div>more content</div><h1>this is a heading<h1><div id="wrapper">Here is some cmmon content that you might find in a website</div><p>qesdafsdafdsa<p>testasingsda<p>tesa</p><h4>here is some more content<h4><h3>asdf</h3><div>more content</div><h1>this is a heading<h1><div id="wrapper">Here is some cmmon content that you might find in a website</div><p>qesdafsdafdsa<p>testasingsda<p>tesa</p><h4>here is some more content<h4><h3>asdf</h3><div>more content</div><h1>this is a heading<h1><div id="wrapper">Here is some cmmon content that you might find in a website</div><p>qesdafsdafdsa<p>testasingsda<p>tesa</p><h4>here is some more content<h4><h3>asdf</h3><div>more content</div><h1>this is a heading<h1><div id="wrapper">Here is some cmmon content that you might find in a website</div><p>qesdafsdafdsa<p>testasingsda<p>tesa</p><h4>here is some more content<h4><h3>asdf</h3><div>more content</div><h1>this is a heading<h1><div id="wrapper">Here is some cmmon content that you might find in a website</div><p>qesdafsdafdsa<p>testasingsda<p>tesa</p><h4>here is some more content<h4><h3>asdf</h3><div>more content</div><h1>this is a heading<h1><div id="wrapper">Here is some cmmon content that you might find in a website</div><p>qesdafsdafdsa<p>testasingsda<p>tesa</p><h4>here is some more content<h4><h3>asdf</h3><div>more content</div><h1>this is a heading<h1><div id="wrapper">Here is some cmmon content that you might find in a website</div><p>qesdafsdafdsa<p>testasingsda<p>tesa</p><h4>here is some more content<h4><h3>asdf</h3><div>more content</div><h1>this is a heading<h1><div id="wrapper">Here is some cmmon content that you might find in a website</div><p>qesdafsdafdsa<p>testasingsda<p>tesa</p><h4>here is some more content<h4><h3>asdf</h3><div>more content</div>'

Teardown



            box.innerHTML = '<h1>this is a heading<h1><div id="wrapper">Here is some cmmon content that you might find in a website</div><p>qesdafsdafdsa<p>testasingsda<p>tesa</p><h4>here is some more content<h4><h3>asdf</h3><div>more content</div><h1>this is a heading<h1><div id="wrapper">Here is some cmmon content that you might find in a website</div><p>qesdafsdafdsa<p>testasingsda<p>tesa</p><h4>here is some more content<h4><h3>asdf</h3><div>more content</div><h1>this is a heading<h1><div id="wrapper">Here is some cmmon content that you might find in a website</div><p>qesdafsdafdsa<p>testasingsda<p>tesa</p><h4>here is some more content<h4><h3>asdf</h3><div>more content</div><h1>this is a heading<h1><div id="wrapper">Here is some cmmon content that you might find in a website</div><p>qesdafsdafdsa<p>testasingsda<p>tesa</p><h4>here is some more content<h4><h3>asdf</h3><div>more content</div><h1>this is a heading<h1><div id="wrapper">Here is some cmmon content that you might find in a website</div><p>qesdafsdafdsa<p>testasingsda<p>tesa</p><h4>here is some more content<h4><h3>asdf</h3><div>more content</div><h1>this is a heading<h1><div id="wrapper">Here is some cmmon content that you might find in a website</div><p>qesdafsdafdsa<p>testasingsda<p>tesa</p><h4>here is some more content<h4><h3>asdf</h3><div>more content</div><h1>this is a heading<h1><div id="wrapper">Here is some cmmon content that you might find in a website</div><p>qesdafsdafdsa<p>testasingsda<p>tesa</p><h4>here is some more content<h4><h3>asdf</h3><div>more content</div><h1>this is a heading<h1><div id="wrapper">Here is some cmmon content that you might find in a website</div><p>qesdafsdafdsa<p>testasingsda<p>tesa</p><h4>here is some more content<h4><h3>asdf</h3><div>more content</div><h1>this is a heading<h1><div id="wrapper">Here is some cmmon content that you might find in a website</div><p>qesdafsdafdsa<p>testasingsda<p>tesa</p><h4>here is some more content<h4><h3>asdf</h3><div>more content</div><h1>this is a heading<h1><div id="wrapper">Here is some cmmon content that you might find in a website</div><p>qesdafsdafdsa<p>testasingsda<p>tesa</p><h4>here is some more content<h4><h3>asdf</h3><div>more content</div>'
        
  

Test runner

Ready to run.

Testing in
TestOps/sec
removeChild
while (box.firstChild) {
  box.removeChild(box.firstChild);
}
ready
removeChild 2
while (box.lastChild) {
  box.removeChild(box.lastChild);
}
ready
innerHTML
box.innerHTML = '';
ready

Revisions

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