Skip to content

Instantly share code, notes, and snippets.

@ORESoftware ORESoftware/example.js
Last active Jan 22, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.