Skip to content

Instantly share code, notes, and snippets.

@AitorAlejandro
Created November 15, 2020 13:35
Show Gist options
  • Save AitorAlejandro/c2d86640c2a8b0b4e8fe4678b1ab5232 to your computer and use it in GitHub Desktop.
Save AitorAlejandro/c2d86640c2a8b0b4e8fe4678b1ab5232 to your computer and use it in GitHub Desktop.
How to find out if the browser tab of the page is focused
const isBrowserTabFocused = () => !document.hidden;
// Example
isBrowserTabFocused(); // true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment