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

Revision 4 of this benchmark created by jd 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

Revisions

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