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

Revision 11 of this benchmark created on


Description

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

Preparation HTML

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

Test runner

Ready to run.

Testing in
TestOps/sec
.getAttribute("id")
var id = element.getAttribute("id");
ready
.id
var id = element.id;
ready
attributes
var attr = element.attributes;
for(var i = 0; i < attr.length; i++) {
  if (attr[i].nodeName === "id")
    break;
}
ready

Revisions

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