Web APIs (Part 3) – Page Visibility API

Tram Ho

Hi everybody. After a pause in the Web APIs series to learn about other miscellaneous things, I’m back today. And my article today will take a look at the Page Visibility API, something we pay little attention to. So what is it, let’s see. Go Go!


The Page Visibility API provides several events that help to track when the document (current window) is visible or hidden .

The Page Visibility API helps in saving resources and improving performance by avoiding the web site from performing unnecessary tasks when the document hidden (when users switch tabs, minimize the browser). We can also use it to count access times, for example.

Brower support

The API is supported in most browsers (including IE10 and IE11 😍 )



In this example, the video will stop when you switch to another tab and play again when you return to that tab, it will be processed in the following code


Today’s article is so short. Hope to be helpful to everyone in some upcoming project. Wished everyone success 😉



Share the news now

Source : Viblo