What is API Page Visibility and how can use it?

In a nutshell it allows you to know when the user leave unattended the browser's tab he were on by either opening a new tab or moving to another one in his browser. Such API had recently upgraded its specification (Level 2) to conform and take advantage of modern browser capabilities. W3C official documentation can be found here.

The importance of this API which is available for everyone and supported by major browsers in their current versions - IE 11 is supported - is that offer a rounded solution for previous implementations that aimed to solve inactivity page state. See what the specification say about the API use case.

As quick closure on the topic I suggest you to leverage what the API can do for you, what can be improved from past solutions and what can be built on top of this web API.