Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

112
Vistas
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 Respuestas
Responde la pregunta

0

I think as like this

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

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda