is there a way, to load some external code during execution of my script? I need something like webpack's require(), but I can't load all the scripts at once (at "compile time"), because there is way too many of them and it would cause enormous performance issues.
In other words, let's say I have some modules:
//modules/module1.js
var Module1 = {
run: function(){...},
data: "SomeData"
}
//modules/module2.js
var Module2 = {
run: function(){...},
data: "SomeData"
}
and then main script which is supposed to load one of them
if(load_module_1){
var module = load("modules/module1.js")
console.log(module.data)
module.run()
...
}
Can it be done? (I want to be able to load "module" into a variable and to keep it isolated from other context.)