jQuery idleTimer plugin – cool plugin to check when a user is idle

Filed under jQuery, Plugins     
29Dec

jQuery idleTimer plugin brings you the idea of knowing when your user is idle.
Why would someone need this kind of functionality. Well there are a few pretty good reasons:

  • you want to make your users come back to your site so you need to grab their attention
  • you want to try and preload more assets
  • you want to use it for your chat client
  • you may want to use it for implementing session time
  • maximize the video screen when user idle for more than x seconds

If you think you need any of the above functionality than you should check out this JQuery plugin created by Paul Irish.

It is really very simple to use the plugin:


// idleTimer() takes an optional argument that defines the idle timeout
// timeout is in milliseconds; defaults to 30000
$.idleTimer(10000);
 
 
$(document).bind("idle.idleTimer", function(){
 // function you want to fire when the user goes idle
});
 
 
$(document).bind("active.idleTimer", function(){
 // function you want to fire when the user becomes active again
});
 
// pass the string 'destroy' to stop the timer
$.idleTimer('destroy');

Share this: