jquery plugin adapter

JavaScript performance comparison

Test case created by chx007

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 
<script>
Benchmark.prototype.setup = function() {
    var count = 100;
    for(var i = 0; i < count; i++) {
      $('body').append('<div id="'+ i +'">'+ i +'</div>');
    }
   
    var $jQuery = function ($) {
      var jQuery = function () {
        return  $.apply(null, arguments);
      };
      jQuery.fn = jQuery.prototype;
      return jQuery;
    };
   
    function SimpleJquery() {
      var jQuery = $jQuery($);
     
      (function($){
        $.fn.abc = function(){};
      })(jQuery);
     
      return jQuery;
    }
   
    (function($){
      $.fn.abc = function(){};
    })(jQuery);
};
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
jquery-plugin
for(var i = 0; i < count; i++) {
  $('#'+i).abc();
}
pending…
jquery-plugin-adapter
var simpleJquery = new SimpleJquery();
for(var i = 0; i < count; i++) {
  simpleJquery('#'+i).abc();
}
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. Here’s a list of current revisions for this page:

0 comments

Add a comment