idle-until-urgent
Defer JS work until the browser has a chance to breathe
Last updated 2 years ago by tehshrike .
WTFPL · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install idle-until-urgent 
SYNC missed versions from official npm registry.

idle-until-urgent

Fetch resources lazily - either whenever the browser is next idle, or when you request the resource.

In a browser that doesn't have requestIdleTimeout, or in node.js, falls back to setTimeout(fn, 1000).

Inspired directly by this ???? post by Philip Walton, but uses a function-based API instead of classes. It's also about a third the size of idlize/defineIdleProperty.mjs (after minification) by avoiding classes and using the dumbest possible requestIdleTimeout fallback.

Install

npm i idle-until-urgent
const makeIdleGetter = require('idle-until-urgent')

Usage

const getFormatter = makeIdleGetter(() => new Intl.DateTimeFormat('en-US', {
	timeZone: 'America/Los_Angeles',
}))

// later in your code, presumably not during the first tick...

getFormatter().format(new Date(1537452915210)) // => '9/20/2018'

License

WTFPL

Current Tags

  • 1.0.0                                ...           latest (2 years ago)

1 Versions

  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (7)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |