1 function sleep(milliseconds) { 2 var start = new Date().getTime(); 3 for (var i = 0; i < 1e7; i++) { 4 if ((new Date().getTime() - start) > milliseconds){ 5 break; 6 } 7 } 8 }
other version to see https://stackoverflow.com/questions/6484321/sleep-in-javascript-no-settimeout?noredirect=1&lq=1