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

Revision 2 of this benchmark created on


Description

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

Preparation HTML

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

Test runner

Ready to run.

Testing in
TestOps/sec
.getAttribute
var id = element.getAttribute("custom");
ready
.attributes
var id = element.attributes['custom'];
ready
attributes again
var id = element.attributes.custom
ready

Revisions

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