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

Can't get CSS to be included synchronously #91

Open
FrDH opened this issue Oct 22, 2024 · 2 comments
Open

Can't get CSS to be included synchronously #91

FrDH opened this issue Oct 22, 2024 · 2 comments
Labels
question Further information is requested

Comments

@FrDH
Copy link

FrDH commented Oct 22, 2024

Question

We're not using critical CSS (maybe some day) and want the CSS to be loaded synchronously, but for some reason setting the 2nd argument to false does not work:

{{ craft.vite.script("src/js/app.ts", false) }}

There is about 2 second FOUC every time I navigate to a new page, which is really annoying for one, but also completely destroys all (the possibility to test) view-transitions.
For now, I resigned to including the CSS in a style tag before including the JS (in local environment only)

{% if craft.app.env == 'local' %}
	<link rel="stylesheet" href="{{ craft.vite.asset('src/scss/app.scss') }}">
{% endif %}
{{ craft.vite.script("src/ts/app.ts", false) }}

Any thoughts?

@FrDH FrDH added the question Further information is requested label Oct 22, 2024
@khalwat
Copy link
Contributor

khalwat commented Oct 23, 2024

You're seeing the FOUC only in local development when using the dev server ya?

@FrDH
Copy link
Author

FrDH commented Oct 25, 2024

Yes, there is no FOUC if the dev server isn't running

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants