r/webdev • u/techie_e • 2d ago
Article GitHub Ditches CSS-in-JS for CSS Modules, Reports 55% Faster SSR after Three-Year Migration
https://www.infoq.com/news/2026/11/github-css-migration/
597
Upvotes
366
u/allurb4se 2d ago
CSS-in-JS always felt like weird to me. Having to convince my then CTO and the senior developer that it made very little sense was a painful and fruitless endeavor
159
u/Nervous-Toe5784 2d ago
The SSR gain makes sense since runtime libs like styled-components or emotion have to serialize and inject styles on every render, and they also need client-side context which doesn't play well with React Server Components. CSS Modules get extracted at build time, so the server just ships static class names and a plain stylesheet. If anyone misses the co-location, zero-runtime options like vanilla-extract or Panda CSS give you most of the DX without the render cost.
135
u/captain_obvious_here back-end 2d ago
I still don't understand how people could think CSS-in-JS was a good idea, and solved anything regular CSS struggled with.
And now it's deep into projects, it probably costs a fortune to migrate out of this.
61
u/The_Peach 2d ago
CSS in JS always felt like the result of a tantrum of a developer that didn't understand the cascading part of CSS
49
u/kisaragihiu 2d ago
article being reported on: https://github.blog/engineering/architecture-optimization/improving-site-performance-by-shipping-more-css/
14
u/lxe 2d ago
Imagine getting paid SF salary to migrate into CSS-in-JS and then back again. For decades ai bet. Frontend engineers have manufactured their own job security for a quarter century now.
9
u/feketegy 2d ago
I feel vindicated after all these years, when this shit was on its peak everybody implemented it, but it did not make any sense, of course, back then too, you were labelled "skill issues" if you said something.
Software development turned into a cult rather than actual work.
37
u/LieNaive4921 2d ago
Three-YEAR migration???
6
u/Brain_itch 2d ago
10 yoe, specializing in web optimization and security
CSSOM is incredibly powerful. You are trying to introduce logic to css using js which seems contrived. CSS native has zero runtime. Lol that is literally the whole point.
Before you shit on css, I implore you try creating a styling system for an erp using css/sass (tho css alone now has many powerful properties- at least sass get translated into css during compilation). JS is runtime. It has blockers, and can get nasty when you dnt know what youre doing
In every project, since 10 years ago, i still abide by the Inverted Triangle CSS (ITCSS) philosophy
If you have played starcraft recently, the remastered version, i lead the engineering of the launcher and every aspect of it. Likewise for overwatch. And league of legends. But heard they swapped architecture since then.
Nevertheless css for the win.
11
u/ringsushy 2d ago
Three years sounds slow until you're ripping runtime styles out of a huge component library without breaking every page.
11
u/AlMasaDuun 2d ago
Do any of you work in a company with more than 3 devs in it? The reason why it became popular is pretty self evident.
5
u/No-Ear843 2d ago
The trendier it is, the more dubious it is. That's sort of a law of modern JavaScript stuff.
3
u/GigaSoup 1d ago
Hahaha, suck it tailwind.
5
u/AssociateChoice384 2d ago
css-in-js always felt like trying to fix a problem that didn't need fixing, like using a sledgehammer to hang a picture. glad they made the switch, performance matters way more than developer convenience some days.
2
u/Miragecraft 2d ago
Forget CSS Modules, just use <style> with donut @scope.
Yes you get repeated <style> tags with duplicate elements, and no it's not a big deal because it compresses easily over the network just like Tailwind tag soup.
2
u/Ok-Interest9727 2d ago
Nature is healing
8
u/VayuAir 2d ago
I am glad the AI era has forced SSR back in focus. I always thought CSR was janky way of doing things
1
u/embGOD 2d ago
Shocked pikachu
1
u/shgysk8zer0 full-stack 2d ago
I'm not a fan of calling that CSS Modules because it's not native CSS modules.
1
u/jchild3rs 1d ago
How is a company this big just learning about this now.
1
u/boer0327 1d ago
runtime style serialization quietly eats so much CPU on every SSR request. moving old styled-components code to CSS Modules gave us our biggest drop in server response times.
1
u/Full_Tooth_a 1d ago
I think styling based on state works fine with CSS Modules. A button can use a class for its variant and `data-loading` for its loading state. For a progress bar, I'd pass the percentage as a CSS custom property. That lets the server render the initial fill without generating a CSS rule for every possible percentage.
1
u/saltyourhash 16h ago
We've known it was faster for years...
1
u/anthony_9245 13h ago
55% faster SSR is a server-rendering result, not automatically 55% faster page loads; the gain depends on whether rendering was the bottleneck.
1
u/TheRNGuy 1h ago
I'll try to remember, I'll use it now too.
1
u/IncomeOk7237 2d ago
curious how much of that 55% is just not doing style serialization on every render. would love to see a before/after flamegraph
0
u/bitterlyFrosty 2d ago
Love SSR since day one
0
u/one944 2d ago
CSS modules clear every tiktok CSS in JS library. It's a very reasonable middle point where only additional tooling is involved.
CSS itself has grown tremendously.
-8
u/Ronin-s_Spirit 2d ago
Both before and after are fucking stupid. From the very beginning they could've had css files for each url route + generic css. Scoping issue in CSS is a skill issue, CSS classes and custom HTML tags have been around for a long time now.
0
u/m0rpeth 2d ago
I am ... shocked. No, really. Who would've guessed.
10
u/MadCervantes 2d ago
Please let css in js die. Fucking terrible from the beginning. A case if js people who don't respect css forcing their shit into the system.