title: Javascript sleep/delay/wait function
body: <p>Sorry if this question has already been asked here before, I could not find a suitable answer.</p>
  
  <p>I am wanting to create a JavaScript sleep/delay/wait function that I can call anywhere in the script, like jQuery's <code>.delay()</code></p>
  
  <p>I am not able to use setTimeout, as I have a script that is generated by php, and so am not able to put it into two different functions, with the timeout in the middle. I need to create a function that allows me to do</p>
  
  <pre><code>alert("time started");
  sleep(4000);
  alert("time up");
  </code></pre>
  
  <p>I <strong>really</strong> do not want to use jQuery.</p>