Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jaubourg
Created August 10, 2011 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaubourg/1138463 to your computer and use it in GitHub Desktop.
Save jaubourg/1138463 to your computer and use it in GitHub Desktop.
jQuery boilerplate suggestion
// remember to change every instance of "pluginName" to the name of your plugin!
// the semicolon at the beginning is there on purpose in order to protect the integrity of your scripts when
// mixed with incomplete objects, arrays, etc.
;(function( $ ) {
// plugin's default options
// this is private property and is accessible only from inside the plugin
var defaults = {
propertyName : 'value'
};
$.fn.pluginName = function( options ) {
// lets merge options with default settings
options = $.extend( {}, defaults, options );
// maintaining chainability
return this.each(function() {
var $this = $( this );
// your code here
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment