I'm importing a .js file to my component with scriptjs and the following code:
declare var externalclass: any;
...
get('http://example.com/path/file.js', () => {
const myclass = new externalclass();
myclass.myfunction();
});
This way, I can call the function myfunction() from the class externalclass of the loaded file. This works fine, but there are multiple instances of the component and depending on other data the component loads other scripts e.g. file2.js, but every file has the same named class externalclass. After all components are loaded, the last loaded file gets used for all components.
Is there a way, to load the .js file but scope it to the component, so that only that specific component can access it, and there are no class name overlaps with other components?