Skip to content

Instantly share code, notes, and snippets.

@guillermoroblesjr
Created November 19, 2015 20:24
Show Gist options
  • Save guillermoroblesjr/42b6b73c1322d651fc7f to your computer and use it in GitHub Desktop.
Save guillermoroblesjr/42b6b73c1322d651fc7f to your computer and use it in GitHub Desktop.
jQuery AMD compatible plugin template
(function(scope, undefined){
var factory = function($){
$.fn.pluginName = function() {};
};
// Set in scope if jquery is already there
if (scope.jQuery !== undefined || scope.$ !== undefined) {
factory(scope.jQuery || scope.$);
}
// AMD. Register as an anonymous module.
else if (typeof scope.define === 'function' && scope.define.amd) {
scope.define(['jquery'], factory);
}
// Browser globals
else {
factory(scope.jQuery || scope.$);
}
})(this || window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment