Skip to content

Instantly share code, notes, and snippets.

@j0lvera
Last active December 15, 2015 15:09
Show Gist options
  • Save j0lvera/5279832 to your computer and use it in GitHub Desktop.
Save j0lvera/5279832 to your computer and use it in GitHub Desktop.
jQuery plugin boilerplate
;(function($, window, document) {
$.fn.pluginName = function(options) {
// defaults
var d = $.extend({
default: 1
}, options);
// settings or bindUI
var s = {
el1 : $('.el1'),
el2 : $('.el2');
};
// plugin logic
var init = function() {
// all the cool stuff your plugin gonna do
s.el1.addClass('someCSS');
// to use a default option use d.default
someHelper(d.default);
};
// helper functions
function someHelper() {
}
// do it
init();
};
})(jQuery, window, document);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment