-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Entry points doesn't inline CSS, but client-side navigation might load another entry point #10285
Comments
Any update on the decision made on this issue? |
I now understand when this happens. IMO we should revert #9761 as it's a regression. |
I think revert #9761 it seems the best chose. 👍 |
Tnx for fixing this issue!
To be clear - what I mean in the 3rd solution is that we can put the JS-inlined-CSS in a different JS file, and load in on The advantage of 3rd solution over the 2nd is that the client wouldn't need to fetch a JS file containing the inlined CSS if the CSS file were already loaded (say, by SSR), and this reduces the number of downloaded bytes on HTTP. |
Describe the bug
I'm just forming the discussion started at #9761 (comment) in a hopefully well formed issue.
This issue is somewhere between a bug and a feature, the best way to see this is as "behavior that was fine and now was stopped working"(after PR #9761).
Problem
Since PR #9761, client side navigation on legacy mode is problematic.
For example, assume hypothetically you have a Nuxt website with the pages "/"(homepage) and "/about", each of them having some CSS.
The user may start in the page "/" and then navigate(**in the client side) to the page "/about", or the opposite, each of the option should be totally valid.
According to Vite, AFAIK, both of the pages are considered to be entry points.
If we're not on legacy mode, everything works well, since both on SSR and client-side navigation, the client always load the relevant
<link>
tags of the CSS files needed.Assuming we're on legacy mode now.
On the first page the user load, there's no need to load JS-inlined CSS, since by SSR there are
<link>
tags referencing to the relevant CSS files. This was the motivation of PR #9761, that canceled CSS-inlining by JS for entry points, since they are already loaded by SSR.But on our case, the SSR loads initially only the CSS files for the first page, but not to the second one.
When the user use the client side navigation to the second page, neither of the CSS files or the JS-inlined CSS is loaded! The former doesn't get loaded because we're on legacy mode, and the second isn't loaded because of PR #9761.
Solutions
As the last paragraph suggests, we have three possible solutions:
Reproduction
See the code and the online preview in the readme desctiption(you need to use legacy browser for see the issue of CSS missing on navigation): https://github.com/Tal500/sveltekit-legacy-demo#online-preview
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: