jQuery.data vs jQuery().data 2 (v66)

Revision 66 of this benchmark created on


Description

jQuery DOM object test against differences. Expecting no performance improvement.

UPDATE: Apparently a saved jQuery object is still ridiculously faster through $.data rather than $.fn.data.

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="el">value</div>
<script>
  var el = $('#el');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery.data
$.data(el, 'key', 'value');
var value = $('#el').html();
ready
jQuery.fn.data
$.data("#el", 'key', 'value');
var value = $("#e1").data('key')
ready

Revisions

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