document.all vs document.getElementsByTagName (v2)

Revision 2 of this benchmark created by Gemorroj on


Description

Speed test for getting all elements on the page

Preparation HTML

<div class="test1"></div>
<div class="test2"></div>
<div class="test3"></div>
<div class="test4"></div>
<div class="test5"></div>
<div class="test6"></div>
<div class="test7"></div>
<div class="test8"></div>
<div class="test9">
        <div class="test10"></div>
        <div class="test11"></div>
        <div class="test12"></div>
        <div class="test13"></div>
        <div class="test14"></div>
        <div class="test15"></div>
        <div class="test16"></div>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
document.all
var els = document.all;
ready
document.getElementsByTagName
var els = document.getElementsByTagName('*');
ready
combine
var els = (document.all) ? document.all : document.getElementsByTagName('*');
ready

Revisions

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

  • Revision 2: published by Gemorroj on