Detect when user switches tabs - Page Visibility API in JavaScript

Detect when user switches tabs - Page Visibility API in JavaScript

In this tutorial we will be using Page Visibility API to detect when the user switches tabs or minimize the window. In this simple example, we will change the website title based on the visibility state, however, you can use it to a bit more advanced cases.