Visibility.js

Visibility.js – a wrapper for the Page Visibility API. It allows you to determine whether your web page is visible to a user, is hidden in background tab or is prerendering. It allows you to use the page visibility state in JavaScript logic and improve browser performance by disabling unnecessary timers and AJAX requests, or improve user interface experience (for example, by stopping video playback or slideshow when user switches to another browser tab).