The visibility API allows a developer to know when a page has lost or gained focus.
The API is particularly useful for saving browser resources by giving developers the opportunity to not perform unnecessary tasks when the webpage is not visible.
If the project doesn't have Jquery this will import it automatically.
ATTENTION: if the user focuses another program that is not the browser the visibility API will not catch the event. (this is the API behavior)
check https://caniuse.com/#feat=pagevisibility to see if your destination browser is compatible