The Page Visibility API
How a page knows you left: document.hidden, visibilitychange, focus and frame timing, with code.
- Page Visibility API explained: document.hidden vs visibilityState document.hidden is a boolean and visibilityState is a string, but both read the same state. How the API works, when it fires, and patterns that hold up.
- requestAnimationFrame in background tabs: why it stops and fixes Browsers pause requestAnimationFrame in hidden tabs, then fire once on return with a big time jump. Why, how to handle the gap, and what keeps work running.
- Page Visibility API test: check what a site sees when you leave Open focus.oddworks.us/test, switch away and come back to see every visibility and focus event a site could catch. Here is what each tile and log entry means.
- How to disable the Page Visibility API: 3 ways, with code Block visibilitychange and pin document.hidden to false with uBlock Origin filters, a Tampermonkey userscript or an extension. Exact code and what each misses.
- Can websites see when you switch tabs? What they detect and how Yes. Any page can tell when its tab is hidden or its window loses focus, but not where you went. Here is what sites detect, why they do it, and how to stop it.