UMD dance-https://github.com/umdjs/umd!function (root, Factory) {if (typeof define = = = ' function ' && define. AMD) {define ([' jquery '], factory); } else {factory (root.jquery); }} (this, function ($) {' Use strict '; Default options var defaults = {}; Constructor, initialise everything you need here var Plugin = function (element, options) {this.element = element; this.options = options; }; Plugin methods and Shared Properties Plugin.prototype = {//Reset Constructor-http://goo.gl/ecwdiy Constructo R:plugin, Somemethod:function () {}}//Create the jQuery Plugin $.fn.plugin = function (options) {//do a Deep copy of the OPTIONS-HTTP://GOO.GL/GOSSRG options = $.extend (true, {}, defaults, options); Return This.each (function () {var $this = $ (this); Create a new instance for each element in the matched JQuery set//Also Save the instance so it can be accessed L Ater to use methods/properties etc e.g. var instance = $ ('. Element '). Data (' plugin '); Instance.somemethod (); $this. Data (' plugin ', new plugin ($this, options)); }); }; Expose defaults and Constructor (allowing overriding of prototype methods for example) $.fn.plugin.defaults = Defaults ; $.fn.plugin.plugin = plugin;}); /use case, Jquery.plugin is the identifier of the above plugin require ([' jquery ', ' jquery.plugin '], function ($) {$ ('. Test li '). Plugin ({test: ' option1 ', Test2: ' Option2 '});
How to retrofit jquery plug-ins with AMD specification examples