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

311
Vistas
How to tell if a script is done loading?

I have a function which at some time does document.getElementsByTagName("script") and it wants to know for each script if it was loaded already.

I'd like to get a Promise which is fulfilled if it was loaded and pending if it's still going on, so I can attach next steps with .then(...) and be sure they get executed.

I could attach a load event I suppose, but if the script was already loaded, I wouldn't ever get the event.

I could work around this by making some assumptions, namely that I am in control of all dynamic script tags, and for static script tags, the document.currentScript is always the last script loaded so far and all preceding scripts are done loading, assuming they were all static. But those assumptions might not always be true.

So, is there a way to check the status and generate Promise that depending on the status will either start as fulfilled (resolved) or be fulfilled by the load event firing?

about 4 years ago · Juan Pablo Isaza
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