Coder Social home page Coder Social logo

What makes styles 'critical'? about usus HOT 2 OPEN

gajus avatar gajus commented on July 21, 2024
What makes styles 'critical'?

from usus.

Comments (2)

gajus avatar gajus commented on July 21, 2024

If you are seeing a big size difference between "critical" CSS generated by usus and CSS generated by other existing tools, chances are that the other tools are simply broken. See this issue for example:

uncss/uncss#313

The "critical CSS" that is generated by uncss is nowhere near the CSS required to load the page.

27978145-e1d7b41c-6365-11e7-8479-79bf5540b8f8

On the other hand, ūsus uses Chrome's CSS coverage tool to determine which CSS was used when loading the page. If elements below the fold have been rendered, CSS for those elements will be included too. It is up to the JavaScript application to avoid rendering those elements if they are not critical (see for example https://github.com/stratiformltd/react-loadable-visibility).

Does this sound reasonable?

I am always open to be corrected.

from usus.

davidhund avatar davidhund commented on July 21, 2024

I have not tested this much t.b.h. but it sounds very reasonable.

I guess there's a balance in dealing with the critical path between size and 'functionality': while other tools might reduce critical CSS size (and therefore might render quicker, but somewhat incorrectly), CSS Coverage might use more CSS (and therefore add to the download weight but render great).

There is a threshold, I believe, where it makes less sense to inline the CSS if it's heavy: because we are essentially duplicating it. Heavy (duplicated) inline CSS + the added complete CSS might (in some cases) reduce rendering performance of the page, compared to not extracting/inlineing critical CSS at all.

In these things it's the developers' responsibility to find the proper balance.

from usus.

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.