Skip to content

Instantly share code, notes, and snippets.

@james2doyle
Created May 7, 2012 13:41
Show Gist options
  • Save james2doyle/2627835 to your computer and use it in GitHub Desktop.
Save james2doyle/2627835 to your computer and use it in GitHub Desktop.
jQuery plugin boilerplate for building proper jQuery plugins
(function($, window, undefined){
$.fn.myPlugin = function(opts) {
var defaults = {
// setting your default values for options
}
// extend the options from defaults with user's options
var options = $.extend(defaults, opts || {});
return this.each(function(){ // jQuery chainability
// do plugin stuff
});
})(jQuery, window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment