RequireJS: Difference between "requirejs" and "require" functions

Matthias Bayer picture Matthias Bayer · Nov 28, 2012 · Viewed 11.6k times · Source

I am using requireJS 2.x. I found out that some tutorials (and the official docs) sometimes use

requirejs.config({ [...] });
requirejs(["module"]) ...

and sometimes

require.config({ [...] });
require(["module"]) ...

Is there any difference between those two functions (require and requirejs)? I could not find any word about that in the docs. :(

Answer

Simon Smith picture Simon Smith · Nov 28, 2012

They are exactly the same.

The reason is some environments might already have a require, in which case RequireJS doesn't overwrite it and allows usage of the library through requirejs

See this commit - https://github.com/jrburke/requirejs/commit/be45948433b053921dc6a6a57bf06d04e13b3b39