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

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

php - facebook and github login HWIOAuthBundle and FOSUserBundle in Symfony2.1 -

hadoop - Sqoop installation export and import from postgresql -