jquery attr(id) vs dom id prop

Benchmark created on


Preparation HTML

<div><div></div>I AM SOME CONTENT LOREM IPSUM DOLOR SIT AMEt<div><a href="http://google.com">non-test text and then <span id="test">test</span></a></div>asdf asdfa ssf saf<span class="filler">jkasdfjkakjdf</span>d</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
  var $test = $('#test');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
jquery attr id
var test_id = $test.attr('id');
ready
dom id prop
var test_id = $test[0].id;
ready

Revisions

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