innerHTML vs removeChild(A slightly lighter html) (v108)

Revision 108 of this benchmark created by prashant sheoran on


Description

what method for empty a element is faster ?

Preparation HTML

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

Setup

var box = document.getElementById('box');
    box.innerHTML = 'sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df'

Teardown


    box.innerHTML = 'sf g<b>s f</b>s df<p>df gsdfg sf g<b>s f</b>s df'
  

Test runner

Ready to run.

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

Revisions

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