I personally like the simple:
function sleep(seconds){
var waitUntil = new Date().getTime() + seconds*1000;
while(new Date().getTime() < waitUntil) true;
}
then:
sleep(2); // Sleeps for 2 seconds
I'm using it all the time to create fake load time while creating scripts in P5js