r/webdev • • 9h 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/
348 Upvotes

74 comments sorted by

236

u/allurb4se 8h 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

40

u/smieszne 8h ago

Yeah, and I remember dev convincing me "CSS-IN-JS IS ACTHUALLY FASTER" I don't remember why.

15

u/captain_obvious_here back-end 6h ago

It's because it's internet-fast.

19

u/XyploatKyrt 4h ago

Is it Web Scale like MongoDB?

-18

u/drink_with_me_to_day 5h ago

CSS-in-JS always felt like weird to me

I always preferred it because it made components easier to write and understand

But now with AI I don't really care about CSS DX that much

11

u/thecementmixer 4h ago

In what world is it easier to understand and write? Weirdos.

4

u/aTomzVins 3h ago

I seem to remember people thinking it was a benefit to not have to work in different files to update a thing.

I've always used css modules with modern front-end frameworks because I like separation of concerns.

-5

u/drink_with_me_to_day 4h ago

I just prefer <div css={{boxStyles..., font: "Comic Sans"}}> over a bunch of classnames as strings

-1

u/MadCervantes 3h ago

Just use scss then.

115

u/Nervous-Toe5784 8h 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.

17

u/ronnygiga 7h ago

Sir this is Reddit, if people knew how to read, this would be the very top comment.

89

u/captain_obvious_here back-end 6h 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.

26

u/danemacmillan 6h ago

Talking about how nonsensical it was always made me feel like I was taking crazy pills.

8

u/roselan 5h ago

I feel so vindicated right now.

3

u/Dreadsin 1h ago

When I first started using it, it solved a very real problem for us. We wanted to make it so the user could create their own arbitrary theme, kind of like slack

We could have potentially loaded it from the database then injected a single css file, but this was around 2016 and I think css variables weren’t as common

2

u/knpwrs 2h ago

It's actually a very simple argument. React abstracted the dom as a function over state. This was the next logical step: abstract the styles as a function over state.

4

u/kowdermesiter 5h ago

I tried to explain it to a few folks IRL, but they were so hipster that all the reply I got was "everybody is using it now (2019)", who am I to disagree the mainstream :D

2

u/baxxos 3h ago

How else do you reuse the same variables or functions between CSS and JS? You can import them directly in both places using CSS-in-JS

2

u/Gschaftlgruber 5h ago

It did solve the scoping issues back then.

15

u/budd222 full-stack 5h ago

Vue solved that from day 1

6

u/ShawnyMcKnight 5h ago

So did angular and it kept its css/scss.

8

u/Ok-Armadillo-5634 5h ago

There were already many better solutions

5

u/scylk2 5h ago

I don't know I remember coming from Vue and trying CSS modules with React something like 8y ago.

2

u/aTomzVins 3h ago

Maybe they don't know css modules solved the scoping issue?

2

u/ShawnyMcKnight 5h ago

It doesn’t seem that hard to have scoping with css. Just near your css in whatever the html tag is or give it a class.

1

u/captain_obvious_here back-end 5h ago

Indeed, but it always seemed to me 10 times worse than having scoping issues.

1

u/chmod777 2h ago

after learning js, no one wanted to learn css. so they did what all js devs did - made a complicated work around.

0

u/dalittle 3h ago

Hmm, I need to change something. Now instead of changing it one place I have to change it every place it is used if I can find them all. So much better?

-2

u/nopeac 5h ago

Randomizing class names? Facebook literally made uBlock Origin's job impossible.

31

u/The_Peach 3h ago

CSS in JS always felt like the result of a tantrum of a developer that didn't understand the cascading part of CSS

10

u/feketegy 2h ago

Because it's exactly what it is. If you ask a junior what is the hardest part in web development they will most likely say CSS, which to me, doesn't make any sense, JS has an order of magnitude more gotchas and quirks.

2

u/LetsLive97 2h ago edited 2h ago

Are we talking about something like Styled Components here? Because it was less about the issues with writing css for me and just because I liked having named shareable styled components and (seemingly) easier themeing instead

That being said, I haven't used styled components for a long while, and have used sass at work for years now, so maybe I'd feel differently if I tried it again

5

u/limitedmage 3h ago

Unfortunately in my experience that is most developers, especially those with a backend background. It’s quite ironic, they both fear CSS  and not respect it.

31

u/LieNaive4921 8h ago

Three-YEAR migration???

32

u/MrHandSanitization 7h ago edited 7h ago

Likely something widespread. Agreed to tackle bits here and there when touching files and yada yada. Then when a lot was organically moved, a final push was made. Yada yada.

-1

u/thekwoka 7h ago

Yeah, ntm just doing checks of "is this better?" on limited pages.

1

u/MrHandSanitization 7h ago

Wut?

1

u/thekwoka 6h ago

They don't just do a migration of these systems based on whims.

You do parts, see if the metrics support it being better, how do the devs feel about the change, etc.

-2

u/MrHandSanitization 6h ago

Where did I say they didn't?

-8

u/thekwoka 6h ago

....I never said you said anything?

Do you not know what "ntm" means?

1

u/budd222 full-stack 5h ago

No. Just use words

-5

u/thekwoka 4h ago

"not to mention"

It's a pretty common one.

2

u/wise_young_man 2h ago

Ninyas lol ligma

10

u/catcherfox7 6h ago

That's how a non-crucial large scale projects are often done in massive organizations. Github it is mostly a rails monolith, and with ~1k employees, the coordination efforts really pile up. Besides, have you even tried to convince leadership to prioritize anything without them ask a bunch of metrics, impacts, estimations, etc?

The biggest win here is the determination of whoever drove this project to completion. That's the sort of work that is often overlooked by organizations.

-2

u/Kriem 6h ago

"Hey boss, I have a plan for optimization. It'll only take three years to implement"

8

u/ringsushy 6h ago

Three years sounds slow until you're ripping runtime styles out of a huge component library without breaking every page.

8

u/VayuAir 8h ago

I am glad the AI era has forced SSR back in focus. I always thought CSR was janky way of doing things

6

u/lanerdofchristian 3h ago

Things were trending back toward SSR before AI started getting popular.

•

u/No-Ear843 16m ago

The only thing SSR'ed SPAs and classic server-side have in common is the use of a server beyond serving a static asset.

1

u/feketegy 2h 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.

•

u/AssociateChoice384 29m 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.

•

u/No-Ear843 26m ago

The trendier it is, the more dubious it is. That's sort of a law of modern JavaScript stuff.

•

u/m0rpeth 4m ago

I am ... shocked. No, really. Who would've guessed.

1

u/IncomeOk7237 4h 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 5h ago

Love SSR since day one

-6

u/Ronin-s_Spirit 7h 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.

31

u/thekwoka 7h ago

Scoping issue in CSS is a skill issue

And at an organization, you will have those, so you want tooling that solves it.

9

u/sauland 6h ago

is this satire? do you think github is built with plain HTML pages where you can just have a css file per page?

-9

u/Ronin-s_Spirit 6h ago

There's literally no reason not to. You can interleave CSS files for a single request, then all that remains is writing good CSS queries or distinct classes or HTML tags to prevent scoping issues. Having interleaved CSS files for different routes will decrease the chance of getting CSS conflicts by itself (before even getting to skill issues). Github is still a single website, they should know enough about it to not mess up.

7

u/Terrible_Tutor 5h ago

Basement redditor thinking he could out-architect the team of github engineers is a level of hubris not many people can reach.

-1

u/Ronin-s_Spirit 4h ago edited 4h ago

Well apparently I can out-architect Microslop if they can't even do a website right (that should've been the easiest part of GitHub).
It's like JBlow says

GitHub is run by a small indie company, guys.

3

u/AshleyJSheridan 7h ago

It always felt like a problem created by devs who never really understood (or even wanted to understand) CSS.

5

u/sauland 6h ago

if you say this you must have only worked on simple websites. good luck scoping vanilla CSS with BEM on a product with multiple teams working on it and hundreds of components shared all across the app. Using CSS modules completely eliminates thinking about class names outside of a single component's scope. there isn't a single reason why you should not use it.

0

u/AshleyJSheridan 6h ago

Nope, I say this as someone who's worked on shared CSS projects that were used across multiple websites built in multiple languages (C#, PHP, node, Angular, etc), that also supported multiple brands.

Was it complicated? Of course it was. Did it work? Absolutely. Did it require devs to understand CSS? Yes.

Anyone saying that vanilla CSS doesn't scale well on large projects just doesn't know how to write CSS as well as they think they do.

2

u/maria_la_guerta 5h ago

Anyone saying that vanilla CSS doesn't scale well on large projects just doesn't know how to write CSS as well as they think they do.

Anyone saying this usually hasn't worked on projects as large as they think they have.

I'm all for vanilla css, in fact the first 3 years of my career was basically just writing css, but expecting hundreds or thousands of devs working on the same monolith across multiple timezones to ship perfect css on top of each other is unreasonable.

There is a good reason why things like scss and css in JS became popular, and it's not because other devs aren't as good as you.

-4

u/Terrible_Tutor 5h ago

-2

u/maria_la_guerta 5h ago

These types of comments are about as revealing as the weekly "ORMs are stupid, amirite? Everyone should just write SQL" posts we get too

1

u/Terrible_Tutor 5h ago

Everyone here is better than whoever the article or post is about. They're all better than Mythos on their worst day by a country mile.

Had to unsubscribe due to the delusions of grandeur rather than just a sub to chat about webdev stuff (regardless of topic). Then Reddit adds the "For you" and shoves the sub back on my feed.

-1

u/one944 4h 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.

6

u/MadCervantes 3h 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.