Why you should stop talking about CSS-in-JS

A brief rant from someone for whom HTML and CSS is real handicraft.

So I’ve just read this article about why you “should definitely learn” to write CSS-in-JS. What shall I say? No offense, but I am a bit disgusted by this.

To me, Brent Jackson seems to be one of those JavaScript Developers who think that coding CSS is a low level skill and that CSS isn’t worth the effort you’ll need to learn and code it.
He seems to be one of those Developers who don’t want to get out of his comfort zone, because this would require to learn something new.

„CSS-in-JS isn’t a boogieman out to destroy everything you love about CSS. In my opinion, it can make authoring CSS far more enjoyable than any other tool I’ve used in the past, and I’d encourage you to give it a shot.“

Dude, you are talking about CSS. You’re not authoring CSS, you’re coding it. Even though CSS is not programming, because it’s declarative not imperative, it’s still code. You don’t write it down like a WhatsApp message or like this rant I’m just writing down here. It. Is. Code. You still have to think (a lot) about what you’re doing.
You also don’t need a single tool to write CSS, besides a Text Editor. This is the purest form of writing this declarative language. Since you’re not talking about SASS, SCSS or LESS, I don’t think that you have understood CSS completely when you’re saying that you need tools after tools to write it.

„If you already know JavaScript, CSS-in-JS helps remove the need to use native CSS syntax, or deal with context switching between different languages.“

Yes, remove native code because you can fuck it all up with JavaScript, right? Context switching, ugh. As a JavaScript Developer this must be the worst part of the whole job. Switching context. What would all the other Developers and Engineers do, if they need to switch contexts? Ah, right. They just do it.

„If you’re less familiar with JS syntax, the effect can be the total opposite, and it can seem like too much to learn at once. Don’t get discouraged. You can still learn how to use CSS-in-JS, and keep in mind that whatever you learn along the way will be applicable knowledge in many other situations where JS is used. I like to think of CSS-in-JS as a potentially low-barrier way to get started with JS.“

So, someone who clearly doesn’t want to get out of his comfort zone to learn something new (a new language to code some native fancy shit) talks about the need to learn something new. Well. It’s JS this time, not CSS, so this is a completely different thing, right? How about you learning native CSS, rather than encouraging others to write a declarative language within an imperative one?

Things I am really asking myself here are:

  • Why would I depend on an additional Library to write otherwise native CSS?
  • Why would I write natively resilient code in a fragile environment?
  • Why would I write a code language in a completely different one?
  • How limited must I be to try to code everything just in the one language I already know?

If you don’t know what you are doing with a coding language (in this case: CSS), then either learn it or leave it. Don’t use half knowledge of something to force push it into something else. Don’t encourage people to use something they don’t understand within something they may not understand either, especially not by saying „Ah, you don’t even need to understand this entirely, because with that it gets so easy.“ Please don’t. Just fucking don’t!

If you hate coding native CSS so much, then please leave it to those who love it. Don’t try to make their jobs and knowledge less important with praising CSS-in-JS because this is so damn easy. This is really not the attitude we need in Frontend Coding.

I wonder what’s your opinion on this? Feel free to leave a comment.