Hacker News new | ask | show | jobs
by pestatije 1995 days ago
What was wrong again with runtime CSS? By the smell of it seems to be performance, so: can somebody point to performance comparisons, or give a brief of the advantages?
2 comments

There's nothing wrong with runtime CSS. Frontend devs just like to come up with elaborate solutions to problems that don't exist
From my understanding of frontend performance, JS parsing is blocking.

So reducing the JS "load" is a performance win on the client.

It’s all about time to interactive.

For a big complex app (eg, https://www.notion.so which I work on), a significant fraction of JS code size is spent describing styles. There can also be JS cycles spent doing color math like lighten, darken, hue shifting on base colors, etc. With runtime CSS-in-JS, all of that style JS code must be parsed and executed by the JS runtime on every page load by every user. That’s a lot of CPU time and user wait time multiplied out.

Zero-runtime improves page load performance by moving this extra code from the JS vm to static CSS files. The majority of style computation happens at build time. The CSS can then be downloaded and parsed in parallel with the JS (woo threads?). The separation may improve caching compared to all-JS solution as well, depending on how granular the CSS and JS output files are.

Oh!, now I get it: CSS static was not good, so welcome JS generated CSS.

But that was not good either, so welcome buildtime JS generated CSS.

Brilliant!

Yes, best of both worlds