Check if loading icon is currently showing in tab
<p>I have a download button on my page to let users download a file.
If the user is pressing the button then the page starts loading which you can see in the tab:</p>

<p><a href="https://i.stack.imgur.com/9DkM8.png" rel="nofollow"><img src="https://i.stack.imgur.com/9DkM8.png" alt="load"></a></p>

<p>How can I get the state?</p>

<p>I tried to get the <a href="https://developer.mozilla.org/de/docs/Web/API/Document/readyState" rel="nofollow">state</a> like this:</p>

<pre><code>console.log(document.readyState);
</code></pre>

<p>But I always get <code>complete</code>.
I also tried to wait first 1 second, because i thought that it shows the status before the user clicked the button:</p>

<pre><code>setTimeout(function(){
  console.log(document.readyState);
  },1000
);
</code></pre>

<p>However, I still get <code>complete</code> even though there is always a loading icon in the tab which stays for about 15 seconds.</p>

<p>How can I check the state?</p>