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

Revision 93 of this benchmark created by Oleksandr Kelepko on


Description

Using jQuery 1.x

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/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
Attribute set
T.attr('data-test', 'ytrewq');
ready
Data get
T.data('test');
ready
Data set
T.data('test', 'ytrewq');
ready
Direct data get
$.data(T, 'test');
ready
Direct data set
$.data(T, 'test', 'ytrewq');
ready

Revisions

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