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

197
Views
How do I control timing of javascript execution in relation to other scripts loading dynamic content?

I've created a small piece of javascript to target some dynamically loaded HTML from a plugin script (YOTPO Reviews).

<script type="text/javascript">
if(window.location.hash) {
    document.getElementsByClassName('write-review-wrapper')[0].style.display = "block";
}
</script>

I'm running into 'x is not defined' type errors and I assume this is because my script is running before the Yotpo widget script has finished loading the HTML I'm selecting?

I know I can execute the script after the DOM has loaded with the window.onload state and this works, however because I've got so many other scripts that are taking time to load in, such as live chat, tracking etc. It's too slow and what I'm trying to achieve becomes somewhat pointless.

The YOTPO script loads in an acceptable time, but how can I get my script to execute just after it's loaded (if that is indeed the issue here)?

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!