dataset vs getAttribute (v2)

Revision 2 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="test" data-set="name"></div>

Test runner

Ready to run.

Testing in
TestOps/sec
dataset read
document.getElementById('test').dataset.set
ready
getAttribute
document.getElementById('test').getAttribute('data-set')
ready
dataset write
document.getElementById('test').dataset.set = 'other-name'
ready
setAttribute
document.getElementById('test').setAttribute('data-set', 'other-name')
ready
jqueryStyle
$('#test').attr('data-set', 'other-name')
ready

Revisions

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

  • Revision 1: published by Florian Margaine on
  • Revision 2: published on
  • Revision 3: published by Florian Margaine on
  • Revision 4: published by David on
  • Revision 5: published by Yuval Aloni on
  • Revision 6: published on