Giter VIP home page Giter VIP logo

Comments (7)

theKashey avatar theKashey commented on June 10, 2024 1

🤘, I hope it would be useful for you. Don't forget to tell friends :)

from used-styles.

theKashey avatar theKashey commented on June 10, 2024

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.

eseQ avatar eseQ commented on June 10, 2024

I can`t understand. Can u provide more complete example? I use simple renderToString

from used-styles.

theKashey avatar theKashey commented on June 10, 2024

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.

eseQ avatar eseQ commented on June 10, 2024

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.

theKashey avatar theKashey commented on June 10, 2024

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.

eseQ avatar eseQ commented on June 10, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.