I'm injecting programmatically some text-code into script, and I need to run some code only after the script is done running.
My code:
const InjectScript = (scriptContent) => {
const script = document.createElement("script");
script.type = "text/javascript";
script.text = scriptContent;
document.head.appendChild(script);
//run some code after script executed
someCode()
};
How can I check if the script is done running?