jQuery.data() vs getAttribute() (v4)

Revision 4 of this benchmark created on


Description

Test the data attribute

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div id="test">
  foo
</div>
<script>
  $el = jQuery(document.getElementById("test"));
  el = document.getElementById("test");
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery.data()
$el.data("searchable", true);
$el.data("searchable");
ready
setAttribute()
el.setAttribute("searchable", true);
el.getAttribute("searchable");
ready
$.data
$.data($el, "searchable", true);
$.data($el, "searchable");
ready

Revisions

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