idle-preload
TypeScript icon, indicating that this package has built-in type declarations

1.0.13 • Public • Published

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

yarn add idle-preload

or

npm i idle-preload --save

Usage

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

Package Sidebar

Install

npm i idle-preload

Weekly Downloads

13

Version

1.0.13

License

MIT

Unpacked Size

11 kB

Total Files

7

Last publish

Collaborators

  • somewind