Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

189
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda