Using setTimeout , you allow the page to be interactive until the checkAuth function checkAuth .
Essentially, you are not allowing checkAuth hold the page.
As a side note, the minimum delay specified in the HTML5 specification is 5 ms, so waiting for 1 ms will really wait for 5 ms. If it is important for you to restore this time, you can achieve the same result with a delay of 0 ms using window.postMessage . This was originally intended to handle reciprocal messaging, but a similar effect as setting a timeout with 0ms (which you cannot do as browsers only allow 5ms - or 10ms in some older browsers).
Finally, time is not guaranteed. JavaScript works in a single thread, so when you push something onto a timer, it must wait for the rest of the JavaScript to open before it starts its turn on the thread - it does not start in parallel.
Fenton
source share