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

190
Vistas
How to execute a function before and after the script is loaded in html?

I have a requirement where I want to execute one function just before the script is starting to load and also execute a function when the script is done loading and executing.

For example, I have the following script attached dynamically to the DOM.

var myScript = $('<div></div>').html("<script src='foo.js'></script>");
document.body.appendChild(myScript);

I want to execute a function showSpinner() before the script starts to load and execute.

and finally, want to execute the function hideSpinner() after the above script is done loading and executing the script.

Note:- I don't want to use any inline code or add a new script file to the server.

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