empty dom node performance test (v3)

Revision 3 of this benchmark created on


Description

common child nodes

Preparation HTML

<div id="test">
 <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
 <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
</div>

Setup

var el = document.getElementById('test'),
        html = el.innerHTML

Teardown


    el.innerHTML = html
  

Test runner

Ready to run.

Testing in
TestOps/sec
removechild
while(el.firstChild){
    el.removeChild(el.firstChild)
}
ready
removechild null !=
while(null != el.firstChild){
    el.removeChild(el.firstChild)
}
ready
cached child
var c;
while(null != (c = el.firstChild)){
    el.removeChild(c)
}
ready
cached child precise
var c;
while(null !== (c = el.firstChild)){
    el.removeChild(c)
}
ready
not cached, precise
while(el.firstChild !== null){
    el.removeChild(el.firstChild)
}
ready

Revisions

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