Real-world CSS vs. CSS-in-JS performance comparison

Click for: original source

CSS-in-JS has taken a solid place in front-end tooling, and it seems this trend will continue in the near future. Especially in the React world. By Tomas Pustelnik.

For example, out of 11492 people who participate in State of CSS survey in 2020 only 14.3% didn’t hear of Styled Components (a dominant CSS-in-JS library). And more than 40% of participants have used the library.

Author wanted to see an in-depth performance comparison of CSS-in-JS libraries like Styled Components and a good old CSS for a long time. Sadly he was unable to found a comparison on a real-world project and not some simple test scenario, so he did it himself.

Don’t use runtime CSS-in-JS if you care about the load performance of your site. Simply less JS = Faster Site. There isn’t much we can do about it. But if you want to see some numbers, continue reading.

The article content:

  • What I measured and how
  • Network comparison
  • Coverage
  • Lighthouse performance audit
  • Performance profiling
  • Comparing user interaction

Runtime CSS-in-JS can have a noticeable impact on your webpage. Mainly for low-end devices and regions with a slower internet connection or more expensive data. Good read!

[Read More]

Tags css frontend javascript web-development ux performance