Check if browser tab is focused

JavaScript, Browser · Oct 20, 2020

Checks if the browser tab of the page is focused.

const isBrowserTabFocused = () => !document.hidden;
isBrowserTabFocused(); // true

More like this