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)?