Consider this scenario for a moment, if you will:
You're viewing a content-heavy site on an iPad, which is set to pre-render content. This is beginning to hammer the resources on the device, with the result that battery power is being drained quickly. Can you do anything about it? Well, on that site, probably not – but if it is a site you own, then yes. Welcome to the Page Visibility API.
The Page Visibility API is a nifty little API that detects when content in a browser tab is visible (that is, being viewed), or hidden. Why is this of interest? Simple – if a browser tab is hidden, then there is no point in playing media on the site, or running frequent polls to a service, right?
The net impact of using this API is aimed at reducing the use of resources and (consequently) saving power. After all, your visitors will not thank you if their batteries are drained as a result of visiting a media-heavy site!
Over the next few pages, we're going to visit...