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

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

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