requestIdleCallback 是否保证执行,是否保留执行顺序?

Does requestIdleCallback guarantee executation, and does it preserve order of execution?

当没有指定 timeout 时,传递给 requestIdleCallback 的函数是否保证为 运行? (假设我们不在某些人为设计的场景中,专门设计用于无限期避免空闲状态)

如果指定了 timeout ,是否可以保证执行顺序?例如

const options = { timeout: 10000 };
requestIdleCallback(fnOne, options);
requestIdleCallback(fnTwo, options);
requestIdleCallback(fnThree, options);

fnOnefnTwofnThree 是否保证每次都按该顺序调用?

Cooperative Scheduling of Background Tasks 说:

During an idle period the user agent will run idle callbacks in FIFO order until either the idle period ends or there are no more idle callbacks eligible to be run. As such, the user agent will not necessarily run all currently posted idle callbacks within a single idle period. Any remaining idle tasks are eligible to run during the next idle period.

因此,我相信在您的示例中,fnOnefnTwofnThree 将按该顺序执行。