jQuery.data vs jQuery().data (v77)

Revision 77 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="el" class="class"></div>
<script>
  var i = 0,
      el = document.getElementById('el'),
      $elId = $('#el'),
      $elClass = $('.class');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery.data
$.data(el, 'key-' + Math.floor(Math.random() * 1001), 'val-' + Math.floor(Math.random() * 1001));
ready
jQuery.fn.data $('.class')
$elClass.data('key-' + Math.floor(Math.random() * 1001), 'val-' + Math.floor(Math.random() * 1001));
ready
jQuery.data $('.class')
$.data($elClass, 'key-' + Math.floor(Math.random() * 1001), 'val-' + Math.floor(Math.random() * 1001));
ready
jQuery.fn.data $('#el')
$elId.data('key-' + Math.floor(Math.random() * 1001), 'val-' + Math.floor(Math.random() * 1001));
ready
jQuery.data $('#el')
$.data($elId, 'key-' + Math.floor(Math.random() * 1001), 'val-' + Math.floor(Math.random() * 1001));
ready

Revisions

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