# on-idle

> Detect when the browser is idle

Latest version **3.1.4** (published 2017-10-17) · 0 weekly downloads

## Install

```sh
npm install on-idle
pnpm add on-idle
yarn add on-idle
bun add on-idle
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.4 |
| Published | 2017-10-17 |
| First published | 2017-03-31 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 80 |
| Maintainers | tuvistavie, yoshuawuyts |
| Keywords | browser, idle, requestIdleCallback |

## Links

- npm: https://www.npmjs.com/package/on-idle
- Repository: https://github.com/choojs/on-idle
- Homepage: https://github.com/choojs/on-idle#readme
- Issues: https://github.com/choojs/on-idle/issues
- npm.io page: https://npm.io/package/on-idle

## Dependencies (1)

- [nanoassert](https://npm.io/package/nanoassert.md) ^1.1.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 3.1.4 (latest) — 2017-10-17
- 3.1.3 — 2017-10-08
- 3.1.2 — 2017-08-15
- 3.1.1 — 2017-08-14
- 3.1.0 — 2017-06-21
- 3.0.2 — 2017-06-17
- 3.0.1 — 2017-06-17
- 3.0.0 — 2017-06-17
- 2.0.0 — 2017-05-30
- 1.1.0 — 2017-04-11
- 1.0.1 — 2017-04-01
- 1.0.0 — 2017-03-31

## README

# on-idle [![stability][0]][1]
[![npm version][2]][3] [![build status][4]][5]
[![downloads][8]][9] [![js-standard-style][10]][11]

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

![on idle console screenshot](./screenshot.png)

## Usage
```js
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](https://tldrlegal.com/license/mit-license)

[0]: https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square
[1]: https://nodejs.org/api/documentation.html#documentation_stability_index
[2]: https://img.shields.io/npm/v/on-idle.svg?style=flat-square
[3]: https://npmjs.org/package/on-idle
[4]: https://img.shields.io/travis/choojs/on-idle/master.svg?style=flat-square
[5]: https://travis-ci.org/choojs/on-idle
[6]: https://img.shields.io/codecov/c/github/choojs/on-idle/master.svg?style=flat-square
[7]: https://codecov.io/github/choojs/on-idle
[8]: http://img.shields.io/npm/dm/on-idle.svg?style=flat-square
[9]: https://npmjs.org/package/on-idle
[10]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[11]: https://github.com/feross/standard

---
_Source: https://npm.io/package/on-idle · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
