to use or not to use getElementById for performance

JavaScript performance comparison

Test case created by

Preparation code

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


Preparation code output

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

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
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.

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