to use or not to use getElementById for performance

JavaScript performance comparison

Test case created

Preparation code

<div id="rumpus"></div>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
without getElementById
rumpus.innerHTML = "roo"
with getElementById
document.getElementById("rumpus").innerHTML = "roo"

Compare results of other browsers


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:

1 comment

Darius commented :

This test is comparing a pre-set variable with inner html used against getElementById with inner html. This cannot be compared. It's like comparing apples to oranges

Comment form temporarily disabled.

Add a comment