queueMicrotask & EventLoop & macrotask & microtask


queueMicrotask

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

scope.queueMicrotask(function);

https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#microtask-queuing


self.queueMicrotask(() => {
  // function contents here
})


MyElement.prototype.loadData = function (url) {
  if (this._cache[url]) {
    queueMicrotask(() => {
      this._setData(this._cache[url]);
      this.dispatchEvent(new Event("load"));
    });
  } else {
    fetch(url).then(res => res.arrayBuffer()).then(data => {
      this._cache[url] = data;
      this._setData(data);
      this.dispatchEvent(new Event("load"));
    });
  }
};

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


macrotask & microtask

https://javascript.info/event-loop

https://zh.javascript.info/event-loop


淺析JS堆、棧、執行棧 和 EventLoop

https://mp.weixin.qq.com/s/Vydvo1PVGgr9zGbYsubX5w

Event loops 秒懂

https://github.com/wangmeijian/blog/blob/master/docs/Event loops秒懂.md

宏任務 task & 微任務 microtask

https://zh.javascript.info/event-loop

https://zh.javascript.info/microtask-queue

critical-rendering-path

前端性能優化

https://developers.google.com/web/fundamentals/performance/critical-rendering-path/render-tree-construction

https://developers.google.com/web/fundamentals/performance/critical-rendering-path/constructing-the-object-model?hl=zh-cn


Flag Counter

©xgqfrms 2012-2020

www.cnblogs.com 發布文章使用:只允許注冊用戶才可以訪問!



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM