Skip to content

Instantly share code, notes, and snippets.

@lpaulger
Last active April 18, 2016 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lpaulger/1ae8a6a828b931831b6884d93309b39d to your computer and use it in GitHub Desktop.
Save lpaulger/1ae8a6a828b931831b6884d93309b39d to your computer and use it in GitHub Desktop.
example UMD module
;(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else if (typeof exports === 'object') {
module.exports = factory(require('jquery'));
} else {
root.MyModule = factory(root.jQuery);
}
}(this, function($) {
'use strict'
var MyModule = {
foo: function() {
//example with external dependency
return $.doSomething();
},
bar: function() {
//content
}
}
return MyModule;
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment