jQuery.data() vs getAttribute()

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>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery.data()
jQuery("#test").data("searchable", true);
jQuery("#test").data("searchable");
ready
setAttribute()
document.getElementById("test").setAttribute("searchable", true);
document.getElementById("test").getAttribute("searchable");
ready

Revisions

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