jQuery.data vs jQuery().data (v67)

Revision 67 of this benchmark created by mdale on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="el" class="cat dog fish size-large"></div>
<script>
  var i = 0,
      el = document.getElementById('el'),
      $el = $(el);
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery.data
var arr = jQuery.grep( $el.attr('class').split(" "), function( str ){
     return ( str.indexOf('size-') === 0 )
})[0];
 
ready
jQuery.fn.data
var getFromVar = "cat dog fish size-large";
var arr = jQuery.grep( getFromVar.split(" "), function( str ){
     return ( str.indexOf('size-') === 0 )
})[0];
ready

Revisions

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