title: Smooth javascript progress bar
body: <p>I'm trying to make a js progress bar which finishes after 5 seconds and then runs some code.</p>
  <p>What I have from w3:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var i = 0;
  function move() {
    if (i == 0) {
      i = 1;
      var elem = document.getElementById("myBar");
      var width = 1;
      var id = setInterval(frame, 10);
      function frame() {
        if (width &gt;= 100) {
          clearInterval(id);
          i = 0;
        } else {
          width++;
          elem.style.width = width + "%";
        }
      }
    }
  }
  
  move();</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>#myProgress {
    width: 100%;
    background-color: grey;
  }
  
  #myBar {
    width: 1%;
    height: 30px;
    background-color: green;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="myProgress"&gt;
    &lt;div id="myBar"&gt;&lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>How can I f.e. adjust its time to 5 seconds, with the animation still being smooth?</p>