TimeMe.js

You have been active on this page for

0 seconds

Demo

Notice the timer above? It is tracking how long you are actively viewing this web page. It is smart enough to stop incrementing when you minimize the browser or if you switch to a different tab. Try it out! It also stops incrementing if you go idle for more than 5 seconds (meaning you don't move the mouse or enter the keyboard for 5 seconds). While 5 seconds is a relatively short time to gauge inactivity, it can be increased to a more realistic value (such as 60 seconds) to determine that a user is no longer viewing the page and has left the browser or computer altogether.

Take a look at the developer console (press F12). You'll see that TimeMe.js also provides hooks when a user leaves the page (due to minimizing browser, switching apps, or going idle). You can use these hooks to execute custom code whenever the user leaves or returns to the page.

More Information

TimeMe.js offers a lot of functionality. See The TimeMe.js github repository for more information.