Is there a way to dynamic load a library in suites...
# suitescript
d
Is there a way to dynamic load a library in suitescript or does everything need to be done at the define? I want to do something like:
Copy code
function someFunction(pathToLibrary) {
  ......load Library
  ......call function in library
}
r
We use this function:
Copy code
function loadModule(modPath) {
    var dyn;
    require([modPath], function(d) {
        dyn = d;
    });

    return dyn;
}
It will return an object for the module.
m
This looks a little dangerous to me because
loadModule()
could return before the require is completed?
r
In server scripts, the require runs synchronously so it won't return before the module is loaded. I haven't tested it client side but I suspect it wouldn't work due to what you mentioned.
d
yeah I am only using it server side