Data attribute vs.jQuery().data vs Attr (v86)

Revision 86 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="el" data-id="1" val="1"></div>
<script>
  var i = 0,
      el = document.getElementById('el'),
      $el = $(el);
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Attr value fetch
$el.attr("val")
ready
Data object reference
$el.data().id;
ready
Data object property fetch
$el.data('id')
ready

Revisions

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