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

111
Views
Cómo verificar si el script terminó de ejecutarse

Estoy inyectando programáticamente un código de texto en el script, y necesito ejecutar un código solo después de que el script haya terminado de ejecutarse.

Mi código:

 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() };

¿Cómo puedo comprobar si el script ha terminado de ejecutarse?

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

0

pienso asi

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

0

async await parece la mejor opción si su tiempo de ejecución está bien con la sintaxis de ECMAScript 2017, así:

 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!