title: Order of execution is not behaving sychronously with tensorflow.js and javascript on the browser
body: <p>I have a simple tensorflow.js application built with jquery and some basic javascript.</p>
  <p>I have button that when clicked, disables itself and toggles a spinner icon to indicate that the model is performing its predictions. When the predictions are finished the default button is restored. However, visually, the UI is not behaving in this way on the browser.</p>
  <p>Demo: <a href="https://maksimdan.github.io/endpoints/models/pokename.htm" rel="nofollow noreferrer">https://maksimdan.github.io/endpoints/models/pokename.htm</a></p>
  <p>If we substitute predictions with a synchronous sleep function, it behaves as expected.</p>
  <pre class="lang-js prettyprint-override"><code>function sleep(ms) {
      return new Promise(resolve =&gt; setTimeout(resolve, ms));
  }
  
  $(&quot;#raw-gen-button&quot;).click(async function(){
      console.log(&quot;Generating new predictions...&quot;);
  
      showButtonId(&quot;#generating-button&quot;);
      await sleep(750);
      // let predictions = await predict_model(5);
      // addGeneratedNamesToUI(predictions);
      showButtonId(&quot;#generate-button&quot;);
  
      console.log(&quot;Finished generating new predictions...&quot;);
      // console.log(predictions);
  });
  </code></pre>