Skip to content

post-task 1.1.5

Install from the command line:
Learn more about npm packages
$ npm install @adevinta/post-task@1.1.5
Install via package.json:
"@adevinta/post-task": "1.1.5"

About this version

@adevinta/post-task

A pre-configured progressively-enhancement utility function based on the Scheduler API.

If the scheduler API is available, use it. If not, but requestIdleCallback is, then use that. Otherwise set a timeout.

The Scheduler API relies on browser heuristics, while the fallbacks wait and call back (in the case of requestIdleCallback, as soon as possible in idle time and definitely at the timeout, for setTimeout only at the timeout).

If not in a browser environment, call back immediately.

The tasks all return a Promise<void> since the scheduler.postTask returns one, but without any return value.

The API is preconfigured with defaults to schedule tasks, based on the scheduler.postTask API.

This function is useful for breaking up chunks of work and freeing the main thread, particularly important when focusing on the Interaction to Next Paint web vital.

Use

import postTask from "@adevinta/post-task";

// ...
postTask(() => {
  trackEvent("something-happened");
}, "background");

Formats

This package is equally available as ESM and CJS and has a single, default export. The code is identical between the formats except on the exporting itself.

Details


Assets

  • post-task-1.1.5.tgz

Download activity

  • Total downloads 0
  • Last 30 days 0
  • Last week 0
  • Today 0

Recent versions

View all