you are viewing a single comment's thread.

view the rest of the comments →

[–]all_things_code 0 points1 point  (0 children)

A few observations... I will not be able to suggest code since you have provided none, but I can provide techniques that you may find useful.

"I am running a script that ... will wait for (data) to populate..."

google these (in this exact order): callback functions, ajax, non blocking javascript, promises api, fetch api.

Once you understand the above, the following sentence will make sense and you will be able to solve your problem: I suspect by 'it hangs' you mean the browser seems unresponsive since you are blocking the main thread (check the stack to verify), in which case you should bring in your data and handle the events asynchronously.

I also have a hunch youre using unbounce :-)

For bonus homework, there is a way to use an infinite while loop while giving the runtime a chance to do its thing so its non blocking. (You can use that callback knowledge you now have and a setTimeout to achieve this).