Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

116
Views
How to check if script done running

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?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

I think as like this

  var IsRunning = false;
  function myFunction() {
   if (!IsRunning) {
    IsRunning = true;
    }
    }
about 4 years ago · Juan Pablo Isaza Report

0

async await seems like the best choice if your runtime is okay with ECMAScript 2017 syntax, like so:

const InjectScript = async (scriptContent) => {
  const script = await document.createElement("script");
  script.type = await "text/javascript";
  script.text = await scriptContent;
  await document.head.appendChild(script);

  //run some code after script executed
  await someCode()
};
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!