Skip to content

Instantly share code, notes, and snippets.

@ORESoftware
Last active January 22, 2016 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ORESoftware/c1d3abb7ff09ecb58f39 to your computer and use it in GitHub Desktop.
Save ORESoftware/c1d3abb7ff09ecb58f39 to your computer and use it in GitHub Desktop.
Example RequireJS synchronous call
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