everything else stops working because you are in synchronous (read, single-threaded) mode starts a loop in which the script gets stuck - since while(true)
- is always executed, because the condition true
always true.
Moreover, since it runs without time limits (no sleep, relatively speaking), it eats CPU resources non-metrically, all other scripts, even asynchronous, may well begin to slow down.
as @Dmitry correctly said, use setInterval
setInterval(function(){ alert("Hello"); }, 3000);
the link example will work in asynchronous mode, causing the function to execute at intervals of 3 seconds
setInterval
- Dmitry