xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

scheduler API All In One

scheduler API All In One


scheduler;
// Scheduler {}[[Prototype]]: SchedulerpostTask: ƒ postTask()constructor: ƒ Scheduler()Symbol(Symbol.toStringTag): "Scheduler"[[Prototype]]: Object

scheduler.__proto__;
// Scheduler {Symbol(Symbol.toStringTag): 'Scheduler', postTask: ƒ, constructor: ƒ}postTask: ƒ postTask()length: 1name: "postTask"arguments: (...)caller: (...)[[Prototype]]: ƒ ()[[Scopes]]: Scopes[0]constructor: ƒ Scheduler()Symbol(Symbol.toStringTag): "Scheduler"[[Prototype]]: Object


scheduler.postTask;
// ƒ postTask() { [native code] }
scheduler.postTask.__proto__;
// ƒ () { [native code] }
scheduler.postTask.__proto__.constructor;
// ƒ Function() { [native code] }

https://caniuse.com/?search=postTask

scheduler.postTask()

移动 Web 应用路线图 > 性能和调优 > 反应性

需要运行长任务的应用(例如在加载页面时)需要在快速加载页面(或减少任务执行时间)与快速响应输入之间进行权衡。
输入事件的早期检测规范提出了 isInputPending 方法,长时间运行的脚本可以同步调用,而不会浪费时间在其他脚本和事件处理上,以检测是否有未处理的输入事件,这些事件的执行可能会延迟触发。

需要运行长任务的应用可能还希望在事件循环之后重新获得控制,并且在其他相同或优先级较低的任务之前运行,scheduler.yield() 函数可以解决该问题。

一般而言,应用在计划任务优先级时几乎没有控制权。scheduler.postTask() 提案将创建一个统一的 API 来安排任务的优先级。

https://www.w3.org/2020/09/web-roadmaps/mobile/performance.zh.html

https://w3c.github.io/web-roadmaps/mobile/performance.zh.html

isInputPending

https://web.dev/isinputpending/

https://caniuse.com/?search=isinputpending
https://caniuse.com/mdn-api_scheduling_isinputpending

Task Scheduler API Specification

https://www.w3.org/TR/task-scheduler/

Background Tasks API / 后台任务 API

requestIdleCallback() & cancelIdleCallback

// 

https://developer.mozilla.org/en-US/docs/Web/API/Background_Tasks_API

https://developer.mozilla.org/en-US/docs/Web/API/Window/requestIdleCallback

https://developer.mozilla.org/en-US/docs/Web/API/Window/cancelIdleCallback

refs



©xgqfrms 2012-2020

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2022-03-24 22:52  xgqfrms  阅读(159)  评论(1编辑  收藏  举报