flâneur — a map of the web's best reading

Page Visibility API - Web APIs | MDN

developer.mozilla.org · 1,042 words · saved by 1 readers

The Page Visibility API provides events you can watch for to know when a document becomes visible or hidden, as well as features to look at the current visibility state of the page. This is especially useful for saving resources and improving performance by letting a page avoid performing unnecessary tasks when the document isn't visible. When the user minimizes the window or switches to another tab, the API sends a visibilitychange event to let listeners know the state of the page has changed. You can detect the event and perform some actions or behave differently. For example, if your web app is playing a video, it can pause the video when the user puts the tab into the background, and resume playback when the user returns to the tab. The user doesn't lose their place in the video, the video's soundtrack doesn't interfere with audio in the new foreground tab, and the user doesn't miss any of the video in the meantime. Visibility states of an are the same as the parent docume

Page Visibility API - Web APIs | MDN Skip to main content Skip to search Page Visibility API Baseline Widely available This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015. Learn more See full compatibility The Page Visibility API provides events you can watch for to know when a document becomes visible or hidden, as well as features to look at the current visibility state of the page. This is especially useful for saving resources and improving performance by letting a page avoid performing unnecessary tasks w

Explore this link on the map →

related reading