My webpage has different js components that handles different business logic. And I'm using RequireJS to manage dependencies. I want to dynamically load the component which is needed.
For example:
define(['something'],function(something){
var processor;
if(userRole === "student"){
//I want to dynamically load studentProcessor.js here;
}
else if(userRole === "teacher"){
//I want to dynamically load teacherProcessor.js here;
}
processor.process();
});
Really appreciate if anyone can tell me what is the best way to handle this.