coderef

Page visibilityBaseline · Widely available

The document.visibilityState and document.hidden properties tell you whether the page is visible to the user (for example, it's not minimized or in a background tab).

Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Jul 29, 2015. Widely available since Jan 29, 2018.

Browser support

DesktopChrome
1–32Not supported
33+Supportedsince Feb 20, 2014
Current: 155
Edge
12+Supportedsince Jul 29, 2015
Current: 154
Firefox
1–17Not supported
18+Supportedsince Jan 8, 2013
Current: 157
Safari
1–6Not supported
7+Supportedsince Oct 22, 2013
Current: 27
MobileChrome Android
18–32Not supported
33+Supportedsince Feb 26, 2014
Current: 155
Firefox Android
4–17Not supported
18+Supportedsince Jan 8, 2013
Current: 157
Safari iOS
1–6Not supported
7+Supportedsince Sep 18, 2013
Current: 27

How to use

This feature is Baseline widely available — use it freely, no fallback needed.

Example

Full syntax and examples are on MDN: hidden.

Feature detection

JS · check before using
if ("Document" in globalThis && "visibilityState" in Document.prototype) {
  // Document.visibilityState is available
}

Sub-features

Support for each part of the feature (3). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
Document.hidden331218733187
Document.visibilityState331218733187
Document.visibilitychange_event62185614.1625614.5