jQuery.data() vs getAttribute() (v6)

Revision 6 of this benchmark created on


Description

Test the data attribute and class

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", true).data("foo", false);
var foo=!jQuery("#test").data("foo");
 
ready
class
var bar=jQuery("#test").addClass("foo").removeClass("foo");
var foo=jQuery("#test:not(.foo)");
ready

Revisions

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