document.all vs document.getElementsByTagName
JavaScript performance comparison
Info
Speed test for getting all elements on the page
Preparation code
<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>
<script>
Benchmark.prototype.setup = function() {
var doc = window.document;
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
document.all |
|
pending… |
document.getElementsByTagName |
|
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:
- Revision 1: published by Daniel15
- Revision 2: published by Gemorroj
- Revision 3: published
0 comments