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

Revision 3 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");
element.setAttribute('custom','no');
ready
.attributes
var id = element.attributes['custom'];
element.setAttribute('custom','no');
ready
attributes again
var id = element.attributes.custom;
id = 'no';
ready

Revisions

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