Safely detect when the browser is idle. Does nothing when run in Node.
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()
}
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.