r/webdev • • 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

121 comments sorted by

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

67

u/smieszne 1d ago

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

30

u/captain_obvious_here back-end 1d ago

It's because it's internet-fast.

35

u/XyploatKyrt 1d ago

Is it Web Scale like MongoDB?

2

u/killerkadooogan 1d ago

like running huge DB through access...

9

u/spezz 1d ago

Faster to copy-paste.

22

u/Leimina 1d ago

It solves things related to CSS code maintainability and dev experience when working on big web apps with big teams of devs with various level of expertise.

So, depending on your context of course, it does make a lot of sense!

Here the news is github ditched runtime CSS-in-JS. StyleX and PandaCSS are build time solutions where issues mentioned in the article just don't happen.

5

u/sataniccode 1d ago

And vanilla-extract

7

u/reddit-poweruser 1d ago

Just being able to define styles on components is a much better developer experience and easier to maintain, in my experience. Obviously there are performance downsides, but the DX is preferable for me. Being able to use a component library where styles can be defined as props directly on the components is way better than managing stylesheets, inheritance, specificity, using string manipulation to manage state, etc.

3

u/incunabula001 1d ago

It was one of those front end dev fads several years back, always thought it was stupid. But here we are with a lot of tech debt due to all that.

1

u/hydraulictrash 16h ago

Same, I’ve never been sold by it, yes you can do easier conditionals and such, but it leads to a lot of duplication and obviously to the article point compute/rendering time overheads

-18

u/drink_with_me_to_day 1d 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

10

u/thecementmixer 1d ago

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

7

u/aTomzVins 1d 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.

-6

u/drink_with_me_to_day 1d ago

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

0

u/14u2c 1d ago

Because you can safely change the style knowing that only one thing is using it, an encapsulated modular component. With a global css file then who knows what will happen. An unknown quantity of curd could have been built on top of those rules and depending on them.

1

u/thecementmixer 1d ago

Scoped CSS has been solved without CSS-in-JS by multiple frameworks already, even before React.

CSS-in-JS, and HTML-in-JS (JSX) is just a travesty.

0

u/14u2c 1d ago

The problem with this thread seems to be that half are talking about before build time and half are talking about after. And that matters a lot.

0

u/thecementmixer 1d ago

It doesn't matter, the concept of css in js is just absurd.

-1

u/MadCervantes 1d ago

Just use scss then.

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.

25

u/ronnygiga 1d ago

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

5

u/Gremlation 1d ago

You're talking to a bot. If you want to read comments like this all day, you can just go to ChatGPT.

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.

13

u/Dreadsin 1d 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

25

u/knpwrs 1d 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.

0

u/Outrageous-Chip-3961 22h ago

that's the issue - as soon as you start actually using them, they suck and waste your time. css modules was by far the best solution and it still is for react projects since they were released. The only next 'logical' addition is to use 'css islands' like Astro. I'd rather have built in css modules under a <ModuleStyles> tag that goes at the bottom of a .tsx file. That would be very helpful!

-2

u/abednego-gomes 22h ago

If you think about it, it's actually illogical. It shouldn't have ever been invented. It reminds me of the days of PHP, where PHP, JS. HtML and CSS were all in the one file.

44

u/danemacmillan 1d ago

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

14

u/roselan 1d ago

I feel so vindicated right now.

7

u/chmod777 1d ago

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

9

u/Gschaftlgruber 1d ago

It did solve the scoping issues back then.

17

u/budd222 full-stack 1d ago

Vue solved that from day 1

9

u/ShawnyMcKnight 1d ago

So did angular and it kept its css/scss.

9

u/Ok-Armadillo-5634 1d ago

There were already many better solutions

5

u/scylk2 1d ago

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

2

u/aTomzVins 1d ago

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

2

u/ShawnyMcKnight 1d 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.

2

u/captain_obvious_here back-end 1d ago

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

6

u/kowdermesiter 1d 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

1

u/static_func 1d ago edited 1d ago

I used it for a client back in like 2016 when all we had was Webpack and gargantuan configuration files. We needed a component library that could be easily used in a bunch of different applications without needing much configuration and CSS-in-JS (styled-components specifically) required zero configuration in people’s build pipelines. The other teams loved it. I also liked being able to keep my styling close to my html and it let me put them in the same file. It always had major tradeoffs but so did the alternatives we had to choose from at the time. We tried CSS Modules first but it used to require some pretty delicate configuration on both the library and application build pipelines and other teams struggled to adopt that version.

These days it isn’t that hard to migrate away from it, and I’ve done exactly that for both that very same client and others in the last few years. AI makes it ridiculously easy to just port a whole project over to Tailwind, which is just better in every way.

1

u/therealslimshady1234 front-end 15h ago

Styled components was the GOAT. Still use it every day. Nothing even comes close to its ease of use and scalability, except other SC-like packages such as Emotion of course

1

u/static_func 13h ago

That isn’t even remotely still true dude. Its scalability is hot garbage, that’s the problem. You should just be using Tailwind or something similar today, which is also far easier to use

0

u/therealslimshady1234 front-end 12h ago

Thats not true, reusability of Styled Components is literally its main selling point

>and then he recommends Tailwind 🤣😭🫩

Tailwind is one of the worst popular CSS frameworks there is (if not THE worst), not just for scalability, but in general. I have never met a senior frontend engineer who recommended it for any of the SaaS I have worked for, and with good reason. Its a complete garbage framework, made popular by AI slop and the script kiddies who joined during the pandemic.

1

u/Outrageous-Chip-3961 22h ago

had a guy i worked with a few years ago sware by it, and he was the senior dev so stuck with them as ftom (I think it was emotion). I hated building out styled components as i was extremely proficient in css. Doing it in vinilla took me 10x less time and was better for the system in general. God I loved it when css modules were released. No brainer. I can't believe github is still using css-in-js, but to your point, i don't know who ever thought it was a good idea beyond a 'good theory'. In practice, they suck, are unnecessary and just wasted everyones time.

1

u/aTaleForgotten 15h ago

Yeah back when i worked frontend, i hated jsx, and i absolutely despised css-in-js, its just so ugly and hacky compared to css

1

u/baxxos 1d 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

1

u/dalittle 1d 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?

-4

u/nopeac 1d ago

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

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

26

u/feketegy 1d 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.

6

u/StillTiredOfThisShit 1d ago

I think the issue here is that CSS has a lot of "you know it or you dont" whereas something like JS lets you "hack" a solution. A lot of the time I will find out something new about CSS and it's literally a matter of "I didn't know that existed so I couldn't utilize it" whereas when I'm trying to do something with JS I can start "building" something to solve a problem that's already solved, and because of that it feels like I'm making progress even though I'm probably doing something that isn't efficient.

4

u/LetsLive97 1d ago edited 1d 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

1

u/PM_ME_UR__SECRETS 16h ago

This has always been kinda nutty to me.

I think some developers just dont grasp the visual aspect of it, compared the the logicistical side of programming languages that come more naturally to them?

I got hired on as the UX/UI guy and when I arrange some items with flexbox the other devs called it CSS magic.

1

u/feketegy 16h ago

Wait until you show them grids

7

u/limitedmage 1d 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.

1

u/ActuaryLate9198 22h ago

Cascading made sense on the document web, it was always undesirable in large component-based codebases. Still is. Not a skill issue.

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.

1

u/Outrageous-Chip-3961 22h ago

literally me. the amount of building component libraries, then migrating them I have done. My career is pretty much just building components over and over again. I moved on from the css-in-js coolaid a whiel back though. Thank fuck. Seemed cool for about a week until i had to go back and do something with them. Took me 10 times longer than just writing pure css.

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.

0

u/Khao8 c# / tech lead 1d ago

🌍🧑‍🚀🔫👨‍🚀 Always has been

37

u/LieNaive4921 1d ago

Three-YEAR migration???

39

u/MrHandSanitization 1d ago edited 1d 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/IanSan5653 1d ago

GitHub runs a ton of React UI. And CSS in JS is difficult to automatically migrate; many declarations are simple but some can be very complex because they can have full JS syntax.

-1

u/thekwoka 1d ago

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

1

u/MrHandSanitization 1d ago

Wut?

1

u/thekwoka 1d 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 1d ago

Where did I say they didn't?

-8

u/thekwoka 1d ago

....I never said you said anything?

Do you not know what "ntm" means?

3

u/budd222 full-stack 1d ago

No. Just use words

-6

u/thekwoka 1d ago

"not to mention"

It's a pretty common one.

3

u/wise_young_man 1d ago

Ninyas lol ligma

11

u/catcherfox7 1d 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.

-1

u/Kriem 1d ago

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

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

10

u/lanerdofchristian 1d ago

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

2

u/No-Ear843 1d 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.

2

u/stjimmy96 1d ago

I have not seen this trend at all. SSR and CSR serve two very different types of apps. In my company we discussed many times whether we should use SSR and we never found a single benefit that is worth the complexity/effort.

We are creating new systems all the time and they all use CSR

1

u/ReneKiller 1d ago

Yeah both have a purpose, but for some time there was a trend, to built even simple static websites with CSR which doesn't make sense at all.

1

u/the_real_some_guy 1d ago

Are you saying that SSR is more complex than CSR? Are you talking about SSR with hydration for CSR, like what Next is famous for?

A tiny PHP file with zero dependencies behind an Apache server is SSR. Not going to get much simpler than that. 

1

u/Okicarde 1d ago

SSR only makes sense if you dont serve an application

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.

4

u/Suspicious-Engineer7 1d ago

Idk why you're down voted. Css modules are the best middle ground. Easier scoping and the file is right there.

-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.

35

u/thekwoka 1d ago

Scoping issue in CSS is a skill issue

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

11

u/sauland 1d 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 1d 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.

11

u/Terrible_Tutor 1d ago

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

-2

u/Ronin-s_Spirit 1d ago edited 1d 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.

6

u/AshleyJSheridan 1d ago

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

5

u/sauland 1d 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.

1

u/AshleyJSheridan 1d 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.

3

u/maria_la_guerta 1d 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.

-5

u/Terrible_Tutor 1d ago

-1

u/maria_la_guerta 1d 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 1d 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.

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.