Comments (7)
from used-styles.
No pitfalls. This is how it's working. That's why you have to moveStyles
to hoist them on top, above any other CSS file, let those CSS files override critical styles:
import { moveStyles } from 'used-styles/moveStyles';
moveStyles();
from used-styles.
I can`t understand. Can u provide more complete example? I use simple renderToString
from used-styles.
Ok, so that's the problem - critical style extracting is working at the Server Side
, but "fixture" is working on the client side.
You named two option:
- Prepare multiple style tags by getCriticalStyles split by source with data-used-styles
- Remove this style after load equal CSS file.
And there is 3rd option:
- hosts (aka move) critical styles above the "real one" - that would fix style declaration ordering and let "real styles" override critical.
So what to do
- on the client side, just after DOMReady/StyleDeclaration/WhenYouAreReady -
moveStyles
. That's all.
from used-styles.
But how to detect when real style loading has been finished? We can have many different files with different weight who has different load time. Do we need to wait for all? Or can we use moveStyles
after each load?
from used-styles.
No, you are calling it once to move inlined styles above any "real" one.
You might remove all inlined styles when all real ones would load, but that's not required.
from used-styles.
Oh ok got it. I just misunderstood. Simple tags order resolve this issue. I thought inlined style (in style
tag) always has more priority than link
tag.
Anyway, sorry for bothering you.
И спасибо за вклад в эту тему. Не так много людей, кто пишет на тему ssr и в частности потокового рендеренга.
from used-styles.
Related Issues (20)
- renderToNodeStream example HOT 4
- TypeError: Cannot read property 'isReady' of undefined HOT 1
- Is moving / removing styles mandatory? HOT 5
- media query support HOT 5
- Support publicURL HOT 8
- Inline full files and exclude them from loading twice HOT 1
- Styles priority HOT 1
- Correct rules order HOT 1
- detect when classes from different files are used on single node
- No dist in published package HOT 3
- Below The Fold
- Unlock selectors on discovery HOT 1
- Styles with same selector and content but different media are missing
- Usage example for CRA HOT 2
- `:not()` pseudo selector support HOT 2
- React 17 support HOT 2
- Rule filtering
- Cloudflare workers compatibility HOT 4
- React 18 (WebPack 5) doesn't work HOT 1
- missing css HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from used-styles.