Skip to content

Instantly share code, notes, and snippets.

@lski
Last active August 29, 2015 14:04
Show Gist options
  • Save lski/eb4b721236ed831552e7 to your computer and use it in GitHub Desktop.
Save lski/eb4b721236ed831552e7 to your computer and use it in GitHub Desktop.
A simple empty template for creating a reuseable module in javascript, that either runs as an amd module or as vanilla code
/*jslint browser: true, white: true */
/*global define, window */
;(function(factory) {
"use strict";
// simply the dependanices required for this module pass in either required module names or the raw objects if amd not found
if (typeof define === 'function' && define['amd']) {
define([], factory);
}
else {
factory();
// To make the returned object globally accessible
// window['mylib'] = factory();
}
})(function() { // pass in the dependancies for this module
"use strict";
// Enter code to run here
return {
// module object to return
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment