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

Prefetch stylesheets #44

Open
aalin opened this issue Nov 14, 2022 · 0 comments
Open

Prefetch stylesheets #44

aalin opened this issue Nov 14, 2022 · 0 comments

Comments

@aalin
Copy link
Contributor

aalin commented Nov 14, 2022

Currently, when a new component renders, it will send the path of its stylesheet in the same patch set as the HTML for the component, which causes the styles to load after the component has been rendered, which causes flashing.

Since all stylesheets are per-component they are usually very small and could easily be prefetched.

It would be nice if it was possible to find all the CSS files for components used on a page so that the files on the current page could load first...

It is probably enough to just use fetch() and let the browser cache the response.

There is also CSS Module Scripts, but this syntax doesn't work in Firefox yet.

await import('/__mayu/static/7OuD0769LzoQV3qjke0rryI9fYFCJYUlpDlKKe9QCJs=.css', { assert: { type: 'css' } })

https://chromestatus.com/feature/5948572598009856

@aalin aalin changed the title Use web workers to cache assets in the background Prefetch stylesheets Nov 14, 2022
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