function sleep(milliseconds) { var start = new Date().getTime(); for (var i = 0; i < 1e7; i++) { if ((new Date().getTime() - start) > milliseconds){ break; } } } other version to see https://stackoverflow.com/questions/6484321/sleep-in-javascript-no…