Skip to main content Accessibility Feedback

UMD

Provides support for JavaScript module bundlers and loaders, as well as global namespacing (like with the other patterns).

Change myPlugin to whatever namespace you’d like to use for your plugin. Can be used with any of the patterns.

/*!
 * UMD Boilerplate
 * (c) 2019 Chris Ferdinandi, MIT License, https://gomakethings.com
 */
//
(function (root, factory) {
	if ( typeof define === 'function' && define.amd ) {
		define([], function () {
			return factory(root);
		});
	} else if ( typeof exports === 'object' ) {
		module.exports = factory(root);
	} else {
		root.myPlugin = factory(root);
	}
})(typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : this, function (window) {

	'use strict';

	// Code goes here...

});