Unexpected JavaScript infinite loop when checking for body tag -


i going asap script checks if body tag loaded, causes whole page freeze.

here is:

while (!document.body)     if (document.body) console.log('loaded'); 

this of course wouldn't work in cases, i'm puzzled why becomes infinite loop , freezes page.

javascript single-threaded. while loop running, nothing else runs, body can't loaded. there's nothing in body of loop changes value of document.body, if it's not set when start, never be.


Comments

Popular posts from this blog

C# random value from dictionary and tuple -

cgi - How do I interpret URLs without extension as files rather than missing directories in nginx? -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -