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
AsyncStyleSheet and auto removing of unused styles #553
Conversation
Generated by 🚫 dangerJS |
Ok I've had a bit of a read of this PR, and I understand it's just at a proof-of-concept stage, but I'm not convinced the problems described in #452 are in need of something like this. But I want to pick up some discussion from there and move it here, in particular: The cons are simply - everything will be rendered in a strange way:
first everything will be rendered, and become invisible.
next styles will arrive to a browser, and whole tree will gain classNames. And regenerated.
then something changes style of component - they will not be changed instantly, but only after few ticks. Ie after flushing new styles to new stylesheet. This seems very much the way Aphrodite works, and in particular the "big problem" of Aphrodite is the way the styles are injected after the markup has hit the page: Khan/aphrodite#76 However, the bigger dealbreaker for me is that ordering of CSS rules become unpredictable: // Default rendering
<Comp/>
// After some user action
<Comp active/>
// Later
<Comp/> If you remove the css from As a result, I'm not inclined to merge this or anything that adds a flash-of-unstyled-markup or involves reordering CSS, but I'm happy to continue the discussion, and I do appreciate the work you've put into this already, @theKashey. |
@geelen - thanks for reply. I would like to discuss this PR.
Next I just propose the way, we use in Yandex for ages. What about "problems":
|
That's what |
The new stylesheet that @geelen wrote that is part of the async SSR effort, should deprecate this effort; Furthermore, I think this AsyncStyleSheet doesn't handle the injection order correctly, which leads to specificity and priority issues on the generated CSS |
I come from here #452
This PR not passing all tests(I dont know why), and linting (ok, this is just proof-of-concept)
What is done here:
What in result