jQuery .data() performance vs .attr() performance (v56)

Revision 56 of this benchmark created by DanDuh on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<div id='theInput' data-someData='rrrrtttppp'>
<script>
  var theInput = $('#theInput');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Attribute get
$(theInput).attr('data-someData');
ready
Data get
$(theInput).data('someData');
ready
Direct data get
$.data(theInput, 'someData');
ready

Revisions

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