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

FOUC when rendering #10

Open
gone opened this issue Feb 11, 2022 · 2 comments
Open

FOUC when rendering #10

gone opened this issue Feb 11, 2022 · 2 comments

Comments

@gone
Copy link
Contributor

gone commented Feb 11, 2022

This is just a shot in the dark, but it looks like https://github.com/allain/x-widget/blob/main/src/later.mjs#L11 and https://github.com/allain/x-widget/blob/main/src/x-widget.mjs#L65
should be RequestAnimationFrame?

@allain
Copy link
Owner

allain commented Feb 11, 2022

Thanks for the feedback.

The purpose of that little bit of code is to try and find a balance between locking up but having no re-layouts, or not locking up and having no a bunch of re-layouts.

If there are slots I do as much dom injections as I can in 250ms and then throw the next batch of work on the next tick.

If I change it to requestAnimationFrame instead of setTimeout it might actually take more time for the whole page to settle down. Since I think setTimeout can fire faster than requestAnimationFrame.

I will give it a shot though and see how it affects things.

@allain
Copy link
Owner

allain commented Feb 15, 2022

My "optimization" was actually causing some weird race conditions switching to requestAnimationFrame fixed those race conditions. It still has pretty gnarly FOUC.

I'm still looking for a solution to that. My best solution is to do some server side rendering, but that's a big piece of code I'd rather not attack until I need to.

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

No branches or pull requests

2 participants