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

Revision 81 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<input type="text" id="theInput" data-foo="bar"></input>
<script>
  var theInput = $('#theInput');
  theInput.attr('someAttr', 'theValue').data('someData', 'theValue');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Attribute get
theInput.attr('data-foo');
ready
Attribute set
 
ready
Data get
theInput.data('foo');
ready
Data set
 
ready

Revisions

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