Skip to content

hoist css external @imports #467

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

Closed
wants to merge 1 commit into from
Closed

hoist css external @imports #467

wants to merge 1 commit into from

Conversation

Fil
Copy link
Contributor

@Fil Fil commented Jan 9, 2024

WIP for #423

bundleStyles correctly puts the @import "url"; lines at the top of its text. In the preview or build scripts, we can easily detect these lines with RegExp and maybe remove them from the bundled CSS—though that is not even strictly necessary.

Hoisting them as stand-alone links (with the additional preconnect) is what will give the performance boost, and it's a bit more difficult, because in both cases (preview and render) we bundle much later than we link, so it looks like we have to change the order of operations. I think it's doable but I'm not fully there yet.

I learned a lot by reading https://sia.codes/posts/making-google-fonts-faster/

`bundleStyles` correctly puts the `@import "url";` lines at the top of its text. In the preview or build scripts, we can easily detect these lines with RegExp and maybe remove them from the bundled CSS—though that is not even strictly necessary.

Hoisting them as stand-alone links is what will give the performance boost, and it's a bit more difficult, because in both cases (preview and render) we bundle much later than we link, so it looks like we have to change the order of operations. I think it's doable but I'm not fully there yet.
@mbostock
Copy link
Member

See #474 for reference using linkedom to parse CSS and find @import rules.

@Fil Fil closed this Nov 11, 2024
@Fil Fil deleted the fil/hoist-css-imports branch November 11, 2024 14:20
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.

2 participants