el.getAttribute("id") vs el.id

JavaScript performance comparison

Test case created by David

Info

Testing element.getAttribute("id") vs element.id

Preparation code

<div id="testID"></div>
<script>
  var element = document.getElementById("testID");
</script>

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
.getAttribute("id")
var id = element.getAttribute("id");
pending…
.id
var id = element.id;
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:

0 comments

Add a comment