Hacker News new | past | comments | ask | show | jobs | submit login
Tasks, microtasks, queues and schedules (2015) (jakearchibald.com)
126 points by rbanffy on Feb 22, 2021 | hide | past | favorite | 10 comments



I didn't realize why my browsers (Firefox, iOS Safari) were correctly handling the tests, despite the article indicating they were not compliant. Then I realized the article is from 2015.

The content is still really useful, though. A good understanding of JS tasks & microtasks and HTML jobs is really useful for diagnosing the inevitable front-end weirdness encountered during development when using any of the major frontend frameworks (which contain a lot of abstraction that separates the developer from these lower-level facets).


The Safari one was only fixed about a year ago: https://webkit.org/blog/10031/release-notes-for-safari-techn.... I remember being excited about the release specifically because of Jake Archibald calling it out.


Good to know!



Year added above. Thanks!


Two learings on my side:

1. Promises are handled in micro-tasks. 2. `element.click()` causes the event to dispatch synchronously. Even on parent elements.


This has been on my bookmark list since I read it many years ago and I reread it whenever I have to refresh on js fundamentals. Kudos for resurfacing it.


Looking at the starting example, I thought "script start" should happen first. "promise2" should be after "promise1", but the rest seem arbitrary, and you shouldn't be writing code where it would matter.


When you’re writing UI frameworks, the differences are regularly essential to understand.


The setTimeout(..., 0) is important to be able to force things to be at the end of the queue after the current task completes. So if you are going to batch requests, your current task can create a bunch that all queue somewhere, and then setTimeout(..., 0) can be used to dispatch them all at once.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: