jQuery .data() performance vs .attr() performance vs elem.getAttribute() (v17)

Revision 17 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js">
</script>
<input type="text" id="theInput" value="foo">
</input>
<script>
  var dom = document.getElementById("theInput");
  var $dom = $(dom);
  $dom.attr('someAttr', 'theValue').data('someData', 'theValue');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
get/set
dom.setAttribute('someAttr', 'test1');
dom.getAttribute('someAttr');
ready
dta
$.data($dom, 'someData', 'test1');
$.data($dom, 'someData');
ready

Revisions

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