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 #51

Open
ehannes opened this issue Nov 17, 2022 · 1 comment
Open

FOUC #51

ehannes opened this issue Nov 17, 2022 · 1 comment

Comments

@ehannes
Copy link
Contributor

ehannes commented Nov 17, 2022

The current solution for setting stylesheet rules creates a lot of FOUC. They are written in a useEffect hook, like this:

  useEffect(() => {
    State.stylesheet.write()
  })

This is problematic, especially for components like oma-site which is not completely rendered before all things inside it is rendered. That means, we are basically writing the Oma stylesheet on DOMContentLoaded, which is terribly late in the rendering process! In oma-site, we set a lot of custom properties that we use on a lot of places. Until the component is rendered, these custom properties are undefined...

Our default breakpoints are working a lot better though, they are not run inside useEffect.

@ehannes
Copy link
Contributor Author

ehannes commented Nov 21, 2022

We have two use cases here:

  1. Load components separately via CDN. -> oma will build one stylesheet per component that we can use for this.
  2. Build components locally with treeshaking -> when building the site locally, that build will extract styles and build one oma stylesheet for the components that we actually use on that particular site.

Alternatives:

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

1 participant