Trigger A Function When The User Goes Idle – idle-tracker

Category: Javascript | September 2, 2020
Author: roderickhsiao
Views Total: 206 views
Official Page: Go to website
Last Update: September 2, 2020
License: MIT


Trigger A Function When The User Goes Idle – idle-tracker


A small idle tracker library that tracks user interactions on the webpage and fires a callback function if the user goes idle.

Default events the library listens for:

  • change
  • keydown
  • mousedown
  • mousemove
  • mouseup
  • orientationchange
  • resize
  • scroll
  • touchend
  • touchmove
  • touchstart
  • visibilitychange

How to use it:

Install the library with package managers.

# Yarn
$ yarn add idle-tracker

$ npm install idle-tracker --save

Import the idle-tracker.

import IdleTracker from 'idle-tracker';

Or load the umd version of the idle-tracker in the document.

<script src="dist/index.js"></script>
<script src="dist/active-events.js"></script>

Create a new Idle Tracker and specify the timeout, callback function, and active events.

var idelTracker = new Tracker({
    timeout: 3000,
    onIdleCallback: idleFunction,
    throttle: 500
    events: activeEvents.default

Start the idle tracker and done.




  • Release 0.0.7


  • Fix function not removed on end

You Might Be Interested In:

Leave a Reply