From 02e806e4ed23d7d6add1a4b17bfc178118cc14f5 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Sat, 21 Jun 2014 10:54:08 +0800 Subject: [PATCH] Update umdjs. --- umdjs.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 umdjs.md diff --git a/umdjs.md b/umdjs.md new file mode 100644 index 000000000..1e4dfa937 --- /dev/null +++ b/umdjs.md @@ -0,0 +1,45 @@ +--- +title: Universal JS module loader +layout: default +--- + +### Basic (with dependency) + +~~~ js +;(function (root, factory) { + + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else if (typeof exports === 'object') { + module.exports = factory(require('jquery')); + } else { + root.YourModule = factory(root.jQuery); + } + +}(this, function (jquery) { + return {}; +})); +~~~ + +### Basic (no dependency) + +~~~ js +;(function (root, factory) { + + if (typeof define === 'function' && define.amd) { + define(factory); + } else if (typeof exports === 'object') { + module.exports = factory(); + } else { + root.YourModule = factory(); + } + +}(this, function () { + return {}; +})); +~~~ + + +### Reference + + * https://github.com/umdjs/umd