Skip to content

Add queueMicrotask() #3033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions features/queue-microtask.yml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this perhaps be a feature called "Microtasks"?

Points in favor:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are no other developer-exposed ways to use microtasks than via the queueMicroTask, then I agree with this suggestion. Let's re-id and re-name this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The concept of microtasks is much, much older than queueMicroTask(), so I think it would be confusing to name it just microtasks. IIRC, the concept was formalized when promises were introduced, but there were similar "delay this work until just before we return to the event loop" concepts around before that too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The counter argument I can see is that, before queueMicrotask, microtasks where only a concept, or a thing browsers did internally, rather than an API developers can use. If this description is correct, then I don't see much confusion in renaming the feature to microtasks, because that word never really matched with anything devs could do before.

Not a hill I will die on though. Happy to keep the proposed name too.

I remember doing setTimeout(1) years ago, is that how we used to queue microtasks before?

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: queueMicrotask()
description: The `queueMicrotask()` method schedules a function to run after the currently running synchronous JavaScript finishes but before returning to the event loop.
spec: https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#microtask-queuing
compat_features:
- api.queueMicrotask
17 changes: 17 additions & 0 deletions features/queue-microtask.yml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated from: queue-microtask.yml
# Do not edit this file by hand. Edit the source file instead!

status:
baseline: high
baseline_low_date: 2020-07-28
baseline_high_date: 2023-01-28
support:
chrome: "71"
chrome_android: "71"
edge: "79"
firefox: "69"
firefox_android: "79"
safari: "12.1"
safari_ios: "12.2"
compat_features:
- api.queueMicrotask