Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

on-idle

3.1.4 • Public • Published

on-idle stability

npm version build status downloads js-standard-style

Safely detect when the browser is idle. Does nothing when run in Node.

on idle console screenshot

Usage

var onIdle = require('on-idle')
var html = require('bel')
 
var cancel = onIdle(function () {
  var el = html`<h1>browser is idle</h1>`
  document.body.appendChild(el)
})
 
if (somethingHappens) {
  cancel()
}

API

onIdle(callback, options)

Call a function when the browser has spare time. Calls it on the next frame if window.requestIdleCallback is not available. Does nothing in Node.

License

MIT

install

npm i on-idle

Downloadsweekly downloads

208

version

3.1.4

license

none

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
Report a vulnerability