<pre>
Experiment to test if we can check if the current window is visible.
Uses the <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API">Page_Visibility_API</a>, or <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame">requestAnimationFrame</a> as fallback.
Try alt-tabbing or ctrl-tabbing to test results.
Tip: Log also written to console, which you can open in another window to monitor state if this window is not visible.
</pre>
Also see:
<a target="_blank" href="https://stackoverflow.com/questions/1060008/is-there-a-way-to-detect-if-a-browser-window-is-not-currently-active/1060034#1060034">1</a><br>
<a target="_blank" href="https://jsfiddle.net/ElMoonLite/29npzx9v/">open in new window</a>
(ctrl-click to open initially invisible)<br>
<hr>
<div>visible now: <span id="visiblenow"></span></div>
Log: (newest events on top)<br>
<div id="log"></div>