Recently, I encountered an issue while working on a chrome extension. It seems that the website is not loading properly when I use a while loop inside an async function.
To investigate this further, I visited the website and executed the following code in the Chrome Dev Inspector console:
async function testFunction(){
while(1) {}
}
testFunction()
This code creates an infinite loop within an async function. While async functions are designed to run concurrently, this particular setup caused the website to stop loading. I tested this by attempting to scroll through the page only to find that the scrollbar was unresponsive, indicating that the website had indeed halted.
EDIT: Now that I have learned that asynchrony does not equate to parallelism like multi-threading, let me elaborate on the actual problem I am facing and seek solutions:
Within a "for loop", I need to insert iframes and then wait for them to load before performing subsequent actions. This process repeats with different iframe sources each iteration. The challenge lies in waiting for the iframe to fully load without resorting to a while loop (which interferes with the loading itself). Any suggestions on how to approach this?