5 ms·
Tasks, microtasks, queues and schedules (2015)
- cmpb 6y agoI 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).
- caillou 6y agoGood to know!
- memco 6y agoThe Safari one was only fixed about a year ago: https://webkit.org/blog/10031/release-notes-for-safari-technology-preview-101/ 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.
- caillou 6y agoTwo learings on my side: 1. Promises are handled in micro-tasks. 2. `element.click()` causes the event to dispatch synchronously. Even on parent elements.
- rjmunro 6y agoLooking 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.
- chrismorgan 6y agoWhen you’re writing UI frameworks, the differences are regularly essential to understand.
- madhadron 6y agoThe 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.
- ivankolev 6y agoThis 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.
- tingletech 6y agodiscussion from 2015 https://news.ycombinator.com/item?id=10072656 https://news.ycombinator.com/item?id=10072656
- dang 6y agoYear added above. Thanks!