downtime

0.1.1 • Public • Published

downtime

Do background work during browser idle time.

const downtime = require("downtime")

API

downtime.do(callback)

  • Schedule callback to run during next idle period
  • Return an id for cancellation purposes
  • Callback is invoked with an IdleDeadline object
downtime.do(function(deadline) {
  // Do background work
})

downtime.dont(id)

  • Cancel callback represented by id
var id = downtime.do(doBackgroundWork)
downtime.dont(id)

Notes

  • Downtime uses requestIdleCallback and cancelIdleCallback where available
  • Fallback technique is based on this gist
  • For best performance, avoid DOM manipulation during idle time

Compatibility

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i downtime

    Weekly Downloads

    4

    Version

    0.1.1

    License

    ISC

    Last publish

    Collaborators

    • ryanve