Skip to content

Instantly share code, notes, and snippets.

@micahwave
Created August 25, 2014 16:52
Show Gist options
  • Save micahwave/3d78acc713ba31301a28 to your computer and use it in GitHub Desktop.
Save micahwave/3d78acc713ba31301a28 to your computer and use it in GitHub Desktop.
Backbone define
(function(root, factory) {
// Set up Backbone appropriately for the environment.
if (typeof exports !== 'undefined') {
// Node/CommonJS, no need for jQuery in that case.
factory(root, exports, require('underscore'));
} else if (typeof define === 'function' && define.amd) {
// AMD
define(['underscore', 'jquery', 'exports'], function(_, $, exports) {
// Export global even in AMD case in case this script is loaded with
// others that may still expect a global Backbone.
root.Backbone = factory(root, exports, _, $);
});
} else {
// Browser globals
root.Backbone = factory(root, {}, root._, (root.jQuery || root.Zepto || root.ender));
}
}(this, function(root, Backbone, _, $) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment