-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[✨] Add "eager" option to useClientEffect$ eagerness #2926
Comments
I thought |
Using it for theming. With this solution, this piece of JS will block rendering (intended), to retrieve the theme and then render correctly once |
OK, that make sense. I think this is out of scope for v1 |
it would be cool but technically very challenging:
I cant think of any way, we can implement this |
If i'm not wrong, you can put scripts wherever you want, even right after opening body tag, and rendering will block there. That's the reason we usually put scripts after all the HTML has been sent right? I mean qwik can send the script tag at any moment and rendering will stop to execute the script, and then continue loading HTML, and after all HTML is loaded it will fire all I'm mistaken? Just as qwik sends its core script ( |
Even if the |
Having looked into the qwikloader, as it is placed at the very end of the HTML so it couldn't be used for resolving QRLs at the timing that components are mounted. |
But that won't work for static site (SSG), plus if its executed when component is mounted there is no difference to |
@felixsanz |
no, what I mean is that SSG doesn't use cookies as there is no server |
@felixsanz |
By the way, it is difficult to do something from the qwik component before the rendering because of the module script is always run after the document's ready.
|
I made a runnable PoC of doing it as a component |
Mmm, it seems to work fine, but I don't understand what's going on. Can you explain a bit? Also, is this expected to be used by the user or integrated in qwik somehow? |
@felixsanz I just implemented the idea explained above.
|
For the theming you actually need to embed a script as high up as you can. I don't think Qwik can ever do what you want with a hook. ClientEffect can do the embedding but it looks overkill for this use case. BTW, another option to prevent theme flashes is to apply all the CSS hiding classes from the start and then when JS is disabled add a style that overrides the hides, like |
Is your feature request related to a problem?
Currently
useClientEffect$()
let you specify how is executed with{eagerness:'visible|load|idle'}
, but all of them are delayed.Can we have something like
eagerness: eager
that puts the script inside<head>
? (before<body>
)Describe the solution you'd like
^
Describe alternatives you've considered
Using a simple <script>, but prefer the qwik's way.
Additional context
No response
The text was updated successfully, but these errors were encountered: