# idle-preload

> preload something when the page is idle

Latest version **1.0.13** (published 2021-12-27) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.13 |
| Published | 2021-12-27 |
| First published | 2019-07-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=6.9 |
| Dependencies | 1 |
| Unpacked size | 10.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | somewind |
| Maintainers | somewind |
| Keywords | idle, preload, idle-preload |

## Links

- npm: https://www.npmjs.com/package/idle-preload
- Repository: https://github.com/somewind/idle-preload
- Issues: https://github.com/somewind/idle-preload/issues
- npm.io page: https://npm.io/package/idle-preload

## Dependencies (1)

- [dom-helpers](https://npm.io/package/dom-helpers.md) ^3.4.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.13 (latest) — 2021-12-27
- 1.0.12 — 2021-12-27
- 1.0.11 — 2020-04-23
- 1.0.10 — 2020-04-23
- 1.0.7 — 2020-04-23
- 1.0.6 — 2020-04-23
- 1.0.5 — 2019-07-30
- 1.0.4 — 2019-07-25
- 1.0.3 — 2019-07-25
- 1.0.2 — 2019-07-25
- 1.0.1 — 2019-07-24
- 1.0.0 — 2019-07-24

## README

# Idle Preload

## Features

Preload something when the page is idle.

Idle detection algorithm：

* After page loaded, use `setTimeout` and record the real callback time delay.
* Compute the variance of multiple callback time delay.
* The page is considered idle and stable when the variance is low.

## Installation

```shell
yarn add idle-preload
```

or

```shell
npm i idle-preload --save
```

## Usage

```js
import { idlePreload } from 'idle-preload'

const preload = idlePreload({
  // options
  // debug: true
})
preload.push(() => {
  // use your code to preload something
  // 
})
preload.start()
```

## Options

* `varianceLimit: Integer` (default **5**),
* `samplingCount: Integer` (default **5**),
* `afterWindowLoad: Boolean` (default **true**),
* `checkTimeInterval: Integer` (default **200**) ms,
* `debug: Boolean` (default **false**)

## License

[MIT](./LICENSE)

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