require

includes and caches a JS/CSS module(s)

promise require(string|array|object url, [function callback,object master] );
urlstring|array|objectthe path to a JS/CSS file(s)
callbackfunctionoptional, a callback function
masterobjectoptional, the value to be passed as the this parameter
promisea "promise" object

Example

webix.require("extras.js"); // "extras.css"

Details

The method is called only once. If you try to include the same module the second time, the command will be ignored.

To include several JS/CSS files, you can provide an array or an object as the first parameter of the method:

// including several files as an array
webix.require([
  "file1.js",
  "file2.js"
], function(){ /*callback*/ });
 
// including several files as an object
webix.require({
  "file1.js": true,
  "file2.js": true
}, function(){ /*callback*/ });

The difference between these two ways is the following:

  • if the files are set in an array, the loading order is sequential: file2.js will be loaded after file1.js;
  • if the files are set in an object, all js files are loaded at the same time and preserving the order of loading is not guaranteed.
Back to top