r/webdev • • Feb 19 '19

Article Why I Write CSS in JavaScript

https://mxstbr.com/thoughts/css-in-js/
0 Upvotes

4 comments sorted by

4

u/hrnsn123 Feb 19 '19

Fast Performance: Send only the critical CSS to the user for a rapid first paint.

It's extremely poor for performance, for caching, parsing to CSSOM, for initial paint and repaints.

Who said the alternative was one bloated css file?

Sorry but imo Shadow DOM CSS + global styles is the better approach.

2

u/wentjun Feb 20 '19 edited Feb 20 '19

Thousands of companies use CSS-in-JS in production, including Reddit, Patreon, Target, Atlassian, Vogue, GitHub, Coinbase, and many more. (including this website)

It is crazy how developers adopt anything 'shiny' or 'up-and-coming' without understanding the real impact and complications. Just because others are doing it, doesn't mean we should blindly adopt it.

/u/hrnsn123 has brought up a very good point.

1

u/Rev1917-2017 Feb 20 '19

Not sure if you are aware, but on Reddit you link a persons username using /u/username syntax instead of @username.

2

u/wentjun Feb 20 '19

Right, got it, thanks!