r/webdev • u/techie_e • 1d 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/
574
Upvotes
355
u/allurb4se 1d 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
157
u/Nervous-Toe5784 1d 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.
130
u/captain_obvious_here back-end 1d 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 1d ago
CSS in JS always felt like the result of a tantrum of a developer that didn't understand the cascading part of CSS
47
u/kisaragihiu 1d ago
article being reported on: https://github.blog/engineering/architecture-optimization/improving-site-performance-by-shipping-more-css/
13
u/lxe 1d 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.
8
u/feketegy 1d 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 1d ago
Three-YEAR migration???
6
u/Brain_itch 1d 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/AlMasaDuun 1d 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.
11
u/ringsushy 1d ago
Three years sounds slow until you're ripping runtime styles out of a huge component library without breaking every page.
5
u/No-Ear843 1d 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 1d 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 1d 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 1d ago
Nature is healing
8
u/VayuAir 1d 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 1d ago
Shocked pikachu
1
u/shgysk8zer0 full-stack 1d ago
I'm not a fan of calling that CSS Modules because it's not native CSS modules.
1
u/Francis4382 1d ago
Makes sense. CSS-in-JS always felt like extra runtime cost for something CSS can do natively now. 55% faster SSR is a big win for a site at GitHub's scale.
1
u/jchild3rs 1d ago
How is a company this big just learning about this now.
1
u/boer0327 20h 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 17h 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/IncomeOk7237 1d 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 1d ago
Love SSR since day one
0
u/one944 1d 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 1d 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 1d ago
I am ... shocked. No, really. Who would've guessed.
10
u/MadCervantes 1d 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.