jQuery.data() vs getAttribute() (v5)

Revision 5 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" data-foo="bar">foo</div>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery.data()
var bar=jQuery("#test").data("foo");
 
ready
attr
var bar=jQuery("#test").attr("data-foo");
ready

Revisions

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