jQuery プラグインのテンプレート

//本体
(function(factory){
  if(typeof module === 'object' && typeof module.exports === 'object'){
    module.exports = factory(require('jquery'), window, document);
  } else {
    factory(jQuery, window, document);
  }
}(function($, window, document, undefined){

	'use strict';
	
	$.fn.myPlugin = function(options){

		options = $.extend({
			position: 'right',
			width: 200,
			fix: false
		}, options);
	
		return this.each(function(){
			//処理
		});
	}
}));

//実行
$(function(){
	$('#mySelector').myPlugin(options);
});

//本体
(function($) {

	$.fn.myPlugin = function(options){

		options = $.extend({
			position: 'right',
			width: 200,
			fix: false
		}, options);
	
		return this.each(function(){
			//処理
		});
	}
})(jQuery);

//実行
$(function(){
	$('#mySelector').myPlugin(options);
});