For those of you that followed The Beginner’s Guide To Writing a jQuery Plugin, you likely noticed those most plugins start off with a basic skeleton.
When it comes to writing code, noticing certain things like that are key to building your own collection of reusable code components.
Based on that series, here’s a reusable skeleton that you can use to begin work with your future jQuery plugins:
[cc lang=”javascript”]
/*
* PLUGIN-NAME
* PLUGIN-DESCRIPTION
*
* Copyright 2011 YOUR-NAME YOUR-WEBSITE-URL
* Released under the MIT License
*/
(function($){
$.fn.PLUGIN_NAME = function(options) {
var opts = $.extend({}, $.fn.PLUGIN_NAME.defaults, options);
return this.each(function() {
});
};
$.fn.PLUGIN_NAME.defaults = {
};
})(jQuery);
[/cc]
You can also download an archive with the skeleton and a copy of a license!
The download includes…
- The jQuery plugin skeleton. Just remember to fill out your name, website, and other information throughout the code.
- A copy of the MIT License. Remember to add your name and contact info! I typically ship my plugins with this particular license, but feel free to include whatever works best for you.
Speak your mind...