$(this).attr('custom') vs $(this).prop('custom') (v3)

Revision 3 of this benchmark created on


Description

Tests for .attr('data') vs .prop('data') when returning a jQuery object (note, not using within .id).

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" custom="bla">test</span></a></div>asdf asdfa ssf saf<span class="filler">jkasdfjkakjdf</span>d</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script>
  var elem = $('#test')[0];
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
.attr('custom')
$(elem).attr('custom');
ready
.prop('custom')
$(elem).prop('custom');
ready
native .getAttribute
elem.getAttribute('custom');
ready

Revisions

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