jQuery.data vs jQuery().data

JavaScript performance comparison

Revision 93 of this test case created by

Preparation code

<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<div id="el"></div>
<script>
  var i = 0,
      el = document.getElementById('el'),
      $el = $(el);
</script>
      
<script>
Benchmark.prototype.setup = function() {
  i++;

};
</script>

Preparation code output

<div id="el"></div> <script> var i = 0, el = document.getElementById('el'), $el = $(el); </script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
jQuery.data
$.data(el, 'key-' + i, 'val-' + i);
pending…
jQuery.fn.data
$el.data('key-' + i, 'val-' + i);
pending…

Compare results of other browsers

Revisions

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

0 Comments