What is define([ , function ]) in JavaScript?

vinzzz picture vinzzz · Jun 5, 2013 · Viewed 182k times · Source

I see this being used all the time in JavaScript:

define(['param1', 'param2'], function() {

});

What is the define function?

Answer

Claudio Redi picture Claudio Redi · Jun 5, 2013

That's probably a requireJS module definition

Check here for more details

RequireJS is a JavaScript file and module loader. It is optimized for in-browser use, but it can be used in other JavaScript environments, like Rhino and Node. Using a modular script loader like RequireJS will improve the speed and quality of your code.