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

187
Views
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
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!