Dynamically load remote javascript into the DOM
npm install remotejs-loader
import remotejs from "remotejs-loader";
remotejs("/path/to/remote/js.js")
.then(() => {
console.log("js.js is ready");
})
.catch(e => {
console.error(e);
});
import remotejs from "remotejs-loader";
remotejs("/path/to/remote/js.js", { forceReload: true })
.then(() => {
console.log("js.js is ready");
})
.catch(e => {
console.error(e);
});
- If the script has already been loaded once, and requested to be loaded again, force the script to rerun by removing the script tag and readding it.
see CONTRIBUTING.MD