Problem statement: I need to call 'a()' from remotely located file a.js
Code change in reactjs
```
const script = document.createElement("script");
script.src = "http://localhost/test/a.js";
script.type = "text/javascript";
script.onload = () => scriptLoaded();
document.head.appendChild(script);````
scriptLoaded = () => {
console.log("Script Loaded")
console.log(window.document.all[2].src)
window.a()
}
File a.js
import b from './b.js';
export default function a () {
console.log("Print a")
}
File b.js
export default function b() {
console.log("Print b")
}
After removing the 'import' snippet and 'export default' from file a.js, I am able to call the method 'a()' from my react js code
function a () {
console.log("Print b")
}```
But I need to include and call the method 'a()' from a.js with the 'import' statement, as the code have dependency on 'b.js' also