Last active
January 22, 2016 02:03
-
-
Save ORESoftware/c1d3abb7ff09ecb58f39 to your computer and use it in GitHub Desktop.
Example RequireJS synchronous call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(['require'],function(require){ // 'require' is a reserved dependency keyword in RequireJS | |
//if we know for sure that some-module is already loaded, then we can load it here synchrounously | |
//we don't even need to reference it in the dependency array above, if we know it's already loaded | |
var module = require('some-module'); | |
}); | |
//the above can shortened to this: | |
define(function(require){ | |
var module = require('some-module'); // *note* if some-module is already loaded in the front-end cache, this is a synchronous operation! | |
}); | |
// are you starting to see it? the two different require styles above are actually equivalent in terms of functionality, but it's easier to think about the second one | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment