Skip to content

Instantly share code, notes, and snippets.

@samlam
Last active June 17, 2017 19:28
Show Gist options
  • Save samlam/3081e4608346d6dd0a5789e143fc5efd to your computer and use it in GitHub Desktop.
Save samlam/3081e4608346d6dd0a5789e143fc5efd to your computer and use it in GitHub Desktop.
Self-Executing Script IIFE with UMD Wrapper
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(factory);
} else if (typeof exports === 'object') {
module.exports = factory;
} else {
root.MYMODULE = factory();
}
})(this, function () {
// do your thing here
});
//reference: https://toddmotto.com/what-function-window-document-undefined-iife-really-means/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment