a way to build complex single-page apps at scale
A Unified Styling Language
Mark Dalgleish
4.2K55

The article helped me to understand the CSS-in-JS movement a bit more. I like some of the concepts with what’s happening, but for me as a WordPress theme developer — there are quite a few butts for me.

Some of this may be way off, and please correct me on points where I’m wrong. I haven’t looked into React and CnJ past a couple articles I’ve read, and tutorials I’ve seen.

A way to build complex single-page apps at scale

React was built by Facebook, for Facebook out of need for something like it. It solved a real problem that a real company had. I think the same can be said for AirBnB and any other large company that is using React to build their software. Any of my further objections don’t apply to these companies at all. I think there is a place for everything, and when React and CnJ is used where they’re supposed to be used — I think it’s a match made in heaven.

However,
CSS-in-JS for WordPress themes? CSS-in-JS for a photographers portfolio? CSS-in-JS for a local news site? I cannot see the usefulness for that. I see only problems:

  1. Technical Debt
    What’s going to happen the CnJ frameworks when the hype ends in 2–3–5 years? When your CSS is tied to react (or whatever is used to render that css), what happens when things change at the package level? You’re now locked in whichever CnJ solution you’re using. And there is no escaping it. Even if you render our and copy your styles — your styles make no sense because class="title-2841hs1"
  2. Limited to the Buzz Technology
    As interesting as it might be — it’s currently limited to React (and maybe some similar modules?). As far as I know, at the moment — the PHP, Ruby, Python communities are left out of this entirely. And I’m not sure how viable this is in Node without React.
  3. Syntax (I had to mention this)
    This is purely personal taste for me, but React is ugly. CSS-in-JS is ugly. Seeing just how ugly React and CnJ is, I have come to a conclusion that React and CSS-in-JS must be really, really good for complex apps.
  4. Learning Curve
    Because people tinker and modify my work, even if there was a way of CSS-in-JS-in-PHP, I just wouldn’t be able to really use it without going against the convention in my community. CSS-in-JS has a high barrier of entry, changing something like the font size here or there suddenly becomes extremely difficult.
  5. Designers who can code? Not anymore.
    This is kind of tied to the previous point — the Learning Curve. It’s rare enough to see designers who write CSS. Designers who can write CSS and JS, with React and CSS-in-JS? That’s asking a little too much I think.
    In my opinion, CSS Is supposed to be simple and easy to use.

So all these thoughts lead me to this — 
Maybe instead of stuffing absolutely everything inside JavaScript, we should be looking for solutions that make sense for people outside isolated communities?

What if instead of focusing on stuffing everything in JavaScript, we built and expanded upon tools that make the web better, like the critical by Addy Osmani mentioned above?

I may be close to an Amish of Web Developers now, but I don’t think CSS-in-JS is the next step for the web. 
I believe that the web should be built with HTML, CSS and JavaScript. We need tools to help us do that.

We don’t need to obfuscate the technology that makes the web tick. We need to embrace it.

That is not to say that we shouldn’t move the web forward. Projects like Google Polymer seem to be a step in the right direction, sadly I haven’t seen too much hype for that recently.

React has it’s place. I understand that. Are there lessons to be learned from React and CSS-in-JS ? Maybe. Should the rest of the web, or CSS Specs try to imitate React? Oh dear, I hope no.