I am curious what are the differences (performance) in writing jQuery plugin, if any?
I saw how this was done in several ways:
1. Using $.extend():
(function($){
$.fn.extend({
newPlugin: function(){
return this.each(function(){
});
}
});
})(jQuery);
2. Your own function:
(function($){
$.fn.newPlugin = function(){
return this.each(function(){
});
}
})(jQuery);
IMHO the second way is a little cleaner and easier to work with, but it looks like there might be some advantage in writing it with $.extend()? Or am I thinking too much about this, there are no distinguishable differences, and is this just a matter of personal preference?
(I would have thought that this would have been asked earlier, but I cannot find it - if it is there, please direct me to it)
source
share