load
Source: /
Loads a JavaScript file from the local file system and runs it.
The file is loaded at the same scope, so any function or variables defined in it will be available from the calling script.
If the script is running sandboxed, the file must be specified as one of the files used by the script.
Files are loaded relative to the main script file being executed.
Examples
// Load the file 'foo.js', and execute it's JavaScript
load("foo.js"); // If 'foo.js' contains just 'x = "hello"', then the following will
console.log(x); // display the string 'hello'
// Load the file 'foo.js', and execute it's JavaScript
load("bar.js"); // If 'bar.js' contains:
// x = function() {
// console.log("hello");
// }
x(); // then the function x() can be called
// Load 'dir/foo.js'
load("dir/foo.js");