Thoughts On CSS-in-JS
January 06, 2020
Tl;dr: I had sort of a fight with a colleague who decided we should remove Styled Components from our code base. He won. We went back to “plain” SCSS and much to my surprise I didn’t feel any pain resulting from this move.
I Had A Crush On Styled Components
So finding out our guys from FED infra decided to ditch it was painful.
Why ditch it? The main reason was bundle size. Styled Components weighing in at 16.4Kb is a bit hefty, and bringing in it’s sister library, Polished will bring that number up by another 10.8Kb.
Why CSS in JS?
So, Am I For Or Against CSS-in-JS?
Well, I’m not really sure.
I mean, you can do pretty much anything with SCSS, from scoped variable declarations to for loops, SCSS is pretty awesome, so I can’t say I felt like a super human while using Styled Components. I had pretty much the same abilities. Which is why after making the move back to SCSS I didn’t really feel it affect my workflow. I was able to deliver at the same pace and my code seemed pretty much the same, reasonable code I produce day to day.
Thinking about it, I may tend be a bit more towards SCSS, mostly because it’s been around for a while. It’s more mature, got great tooling around it and more people speak it.