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

Defer render to requestAnimationFrame() to avoid unnecessary rerenders #12

Closed

Conversation

patricknelson
Copy link
Owner

@patricknelson patricknelson commented Jun 16, 2023

Defer render to requestAnimationFrame() to avoid unnecessary rerenders until time to paint (particularly if already disconnected). Came up in sveltejs/svelte#8377 (comment):

In my testing, I noticed that when running as a deferred module, it saved from pointless renders that would been eventually disconnected/reconnected anyway. However, the biggest improvements (at least on avoiding wasted rerenders) were in using iife or umd (running early prior to parsing): There were lots of disconnects but also it was able to defer "just in time" during DOM mutations so that it only renders the 1 time prior to repaint, which helped a bunch.

Tasks:

  • Defer Svelte component rendering to rAF
  • Fix broken unit tests which rely on synchronous rendering (i.e.: literally every single one of them)
  • TODO: Consider making this optional. If so, default enabled or disabled? If so, doc in README.md.
  • Create new unit tests to validate the new deferred rendering functionality is working properly
  • Update version, bump minor ver

…d unnecessary rerenders until time to paint (particularly if already disconnected).
…alidate that redundant/unnecessary requests to rAF are skipped.
@patricknelson
Copy link
Owner Author

Closing. Will be made irrelevant once the PR for issue #10 is applied, since the solution to that utilizes renderAnimationFrame() to queue rendering in all circumstances. Keeping note of this PR though since it addresses issues with unit tests.

@patricknelson patricknelson mentioned this pull request Sep 30, 2023
6 tasks
@patricknelson patricknelson deleted the experimental-defer-request-animation-frame branch September 30, 2023 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant