jQuery Boilerplate versus Custom

Benchmark created by Diego Lopes Lima on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
Custom
(function(e,t){var n=t.document,r={methodName:{propertyName:"value"}};e.extend({methodNameSetup:function(t){return r.methodName=e.isPlainObject(t)&&!e.isEmptyObject(t)?e.extend(r.methodName,t):r.methodName},methodName:{version:"1b"}}),e.fn.extend({methodName:function(t){return t=e.isPlainObject(t)&&!e.isEmptyObject(t)?e.extend(r.methodName,t):r.methodName,e(this).each(function(){})}})})(jQuery,window)
ready
jQuery Boilerplate
(function(e,t,n){function o(t,n){this.element=t,this.options=e.extend({},s,n),this._defaults=s,this._name=r,this.init()}var r="defaultPluginName",i=t.document,s={propertyName:"value"};o.prototype.init=function(){},e.fn[r]=function(t){return this.each(function(){e.data(this,"plugin_"+r)||e.data(this,"plugin_"+r,new o(this,t))})}})(jQuery,window)
ready
Custom 2
(function(e,t){var n=t.document,r={methodName:{propertyName:"value"}},i={methodName:function(t){return t=e.isPlainObject(t)&&!e.isEmptyObject(t)?e.extend(r.methodName,t):r.methodName,e(this).each(function(){})}};for(plugin in i)e[plugin+"Setup"]=function(t){return r[plugin]=e.isPlainObject(t)&&!e.isEmptyObject(t)?e.extend(r[plugin],t):r[plugin]};e.fn.extend(i)})(jQuery,window)
ready
Custom 3
(function(e,t){var n=t.document,r={method:{propertyName:"value"},fnMethod:{propertyName:"value"}},i={methodSetup:function(t){return r.method=e.isPlainObject(t)&&!e.isEmptyObject(t)?e.extend(r.method,t):r.method},fnMethodSetup:function(t){return r.fnMethod=e.isPlainObject(t)&&!e.isEmptyObject(t)?e.extend(r.fnMethod,t):r.fnMethod},methodInfo:{version:"1b"},fnMethodInfo:{version:"1b"}};e.extend(e.extend(i,{method:function(){return!0}})),e.fn.extend({fnMethod:function(t){return t=e.isPlainObject(t)&&!e.isEmptyObject(t)?e.extend(r.methodAName,t):r.methodAName,e(this).each(function(){})}})})(jQuery,window)
ready

Revisions

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

  • Revision 1: published by Diego Lopes Lima on