Document.hidden is a read-only instance property that returns true when the page is not visible to the user (background tab, minimized window, etc.). Learn the Page Visibility API, MDN’s visibilitychange example, pausing media, and five examples with try-it labs.
01
Kind
Read-only
02
Returns
boolean
03
true
Tab hidden
04
Event
visibilitychange
05
vs
visibilityState
06
Status
Baseline widely
Fundamentals
Introduction
When a user switches tabs or minimizes the browser, your page may still run JavaScript—but it is no longer visible. document.hidden tells you that in one boolean value.
MDN: the read-only property returns whether the page is considered hidden. Use it to check whether the document is in the background, minimized, or otherwise not visible to the user. It is part of the Page Visibility API.
💡
Why it matters
Pause videos, stop animations, reduce polling, and save battery when document.hidden is true. Resume when the user returns and it becomes false.
Document.hidden is marked Baseline Widely available on MDN (since July 2015). Logos use the shared browser-image-sprite.png sprite from this project.
✓ Baseline · Widely available
Document.hidden
Read-only boolean for Page Visibility — detect background tabs and hidden pages.
UniversalWidely available
Google ChromeFull support · Desktop & Mobile
Full support
Mozilla FirefoxFull support · Desktop & Mobile
Full support
Apple SafariFull support · macOS & iOS
Full support
Microsoft EdgeFull support · Chromium
Full support
OperaFull support · Modern versions
Full support
Internet ExplorerSupported in legacy IE
Full support
Document.hiddenExcellent
Bottom line: Listen for visibilitychange and read document.hidden to pause media, stop polling, and save resources when the user is not viewing the page.
Wrap Up
Conclusion
Document.hidden is a simple, widely supported way to know whether your page is visible. Pair it with visibilitychange to pause media, stop timers, and build battery-friendly experiences.
Pause media and heavy timers when document.hidden is true
Use visibilityState when you need prerender detail
Resume gracefully when the tab becomes visible again
Combine with user preferences (autoplay policies)
❌ Don’t
Assign to document.hidden — it is read-only
Assume focus and visibility are always the same
Keep aggressive polling running in hidden tabs
Forget mobile browsers also fire visibility events
Block critical saves solely on visibility without a fallback
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about document.hidden
Page Visibility in one boolean.
5
Core concepts
📄01
Returns
boolean
API
👁02
true
Tab hidden
Background
🔄03
Event
visibilitychange
MDN
🎬04
Pause
media / timers
UX
⚖️05
vs
visibilityState
Alternative
❓ Frequently Asked Questions
A boolean: true if the page is considered hidden (background tab, minimized window, or otherwise not visible to the user), false otherwise (MDN).
No. MDN marks Document.hidden as Baseline Widely available (since July 2015). It is part of the standard Page Visibility API.
document.hidden is a simple true/false. document.visibilityState returns a string such as visible, hidden, or prerender — MDN notes it as an alternative way to determine whether the page is hidden.
When the user switches tabs, minimizes the window, or the page is otherwise not visible — common cases for saving battery and pausing media.
The visibilitychange event on document. Read document.hidden inside the handler to react when visibility changes (MDN example).
No. It is a read-only property. You observe visibility; you cannot force the page hidden state from script.
Did you know?
Mobile browsers fire visibilitychange when users switch apps or lock the screen—not only when changing browser tabs. That makes document.hidden especially useful for saving battery on phones.