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

Revision 100 of this benchmark created by Mike McCaughan on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="test" data-test="qwerty"></div>
<script>
  var T = $('#test');
</script>

Test runner

Ready to run.

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

Revisions

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