Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
Adds scheduler.yield callout in the Optimize Long Tasks guide. (#10362
Browse files Browse the repository at this point in the history
)

* Adds scheduler.yield callout in the Optimize Long Tasks guide.

* Updates the updated field.

* Update src/site/content/en/blog/optimize-long-tasks/index.md
  • Loading branch information
malchata authored Aug 26, 2023
1 parent 37b46c9 commit 817ded8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/site/content/en/blog/optimize-long-tasks/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ subhead: |
authors:
- jlwagner
date: 2022-09-30
updated: 2022-10-03
updated: 2023-08-28
hero: image/jL3OLOhcWUQDnR4XjewLBx4e3PC3/MpP0GrDpLMztUsdMocP9.jpg
thumbnail: image/jL3OLOhcWUQDnR4XjewLBx4e3PC3/Eup7oLu7L0bglCH4YPGq.jpg
alt: A photograph of a spool of purple thread unraveling to the right until it goes out of the frame.
Expand Down Expand Up @@ -349,9 +349,13 @@ This is a simplistic example of how `postTask()` can be used. It's possible to i
[`postTask()` is not supported in all browsers](https://caniuse.com/mdn-api_scheduler_posttask). You can use feature detection to see if it's available, or consider using [a polyfill](https://www.npmjs.com/package/scheduler-polyfill).
{% endAside %}
### Built-in yield with continuation
### Built-in yield with continuation via `scheduler.yield`
One proposed part of the scheduler API that's not currently implemented in any browser is a built-in yielding mechanism. Its use resembles the `yieldToMain()` function demonstrated earlier in this article:
{% Aside 'important' %}
For a more detailed explanation on `scheduler.yield`, read [this post about its origin trial](https://developer.chrome.com/blog/introducing-scheduler-yield-origin-trial/), as well as [its explainer](https://github.com/WICG/scheduling-apis/blob/main/explainers/yield-and-continuation.md).
{% endAside %}
One proposed part of the scheduler API is `scheduler.yield`, an API specifically designed for yielding to the main thread in the browser [which is currently available to try as an origin trial](https://developer.chrome.com/origintrials/#/view_trial/836543630784069633). Its use resembles the `yieldToMain()` function demonstrated earlier in this article:
```js
async function saveSettings () {
Expand Down

0 comments on commit 817ded8

Please sign in to comment.