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

Revision 51 of this benchmark created on


Preparation HTML

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<input type="text" id="theInput" value="foo"></input>
<script>
  var theInput = $('#theInput');
 
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Attribute get
// async test
theInput.attr('someAttr');
ready
Attribute set
theInput.attr('someAttr', 'newValue');
ready
Data get
// async test
theInput.data('someData');
ready
Data set
theInput.data('someData', 'newValue');
ready
Direct data get
// async test
$.data(theInput, 'someData');
ready
Direct data set
$.data(theInput, 'someData', 'newValue');
ready

Revisions

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