title: 'beforeunload' event triggers when page is left in the background on Android
body: <p>I'm trying to make a simple loading spinner that pops up when navigating. It shows up using a 'beforeunload' event when navigating away and uses the 'load' event to hide itself again when it is done.</p>
  
  <p>The problem is that when I leave the page in the background on my phone for e.g. a few hours the 'beforeunload' event triggers and displays the spinner. Probably because Chrome on Android is partially unloading the page to save memory. The spinner doesn't go away by itself though and I can't seem to figure out how to make it disappear again in an elegant way.</p>
  
  <p>Is there any other event I should be using instead?</p>
  
  <pre class="lang-js prettyprint-override"><code>    window.addEventListener("load", function() {
          topSpinner.classList.add("closed");
      });
  
      window.addEventListener("beforeunload", function() {
          topSpinner.classList.remove("closed");
      });
  </code></pre>