4 ms·
This comment has nothing to do with Backbone but we tend to use the sugar syntax for defines: define(function(require){ var whatever = require('dependency');
by paduc 14y ago
This comment has nothing to do with Backbone but we tend to use the sugar syntax for defines:
define(function(require){
var whatever = require('dependency');
});
instead of
define([
'dependency',
], function(whatever) {
});
We do this because it's way more readable for files with numerous dependencies.
Also, we make Backbone, $ and _ globals so we don't have to inject them in every single module.
- Cthulhu_ 14y ago> Also, we make Backbone, $ and _ globals so we don't have to inject them in every single module. We don't; we explicitly define every dependency, always, so that it does not make any assumptions about the environment it runs in (a webpage with jquery / underscore included via script tags, for example). Second, our end-product is a single .js with Backbone and some other dependencies all combined into it. (we're not allowed to use a CDN)
- paduc 14y agoThat sounds like a pretty good reason not to make those globals. We did it when we realized 100% of our modules had those three dependencies. Haven't found a drawback yet.