Skip to content
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

Leverage scheduler.yield() in @wordpress/interactivity'ss splitTask() when available #64483

Closed
westonruter opened this issue Aug 13, 2024 · 1 comment · Fixed by #66001
Closed
Assignees
Labels
[Packages] Interactivity /packages/interactivity [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Comments

@westonruter
Copy link
Member

There is a TODO in this splitTask() function:

/**
* Returns a promise that resolves after yielding to main.
*
* @return Promise
*/
export const splitTask = () => {
return new Promise( ( resolve ) => {
// TODO: Use scheduler.yield() when available.
setTimeout( resolve, 0 );
} );
};

Chrome just announced the intent to ship this (where previously it was behind an origin trial). Once it is available we can leverage it for better yielding to the main thread as described in the Optimize long tasks article on Web.dev.

@westonruter westonruter added [Type] Enhancement A suggestion for improvement. [Packages] Interactivity /packages/interactivity labels Aug 13, 2024
@swissspidy
Copy link
Member

Looks like this shipped now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Packages] Interactivity /packages/interactivity [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants