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

Benchmark created by David on


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.