The conventional wisdom in web performance has long been: ship less CSS. Fewer bytes, faster paints, happier users. But a deep dive into the GitHub Engineering Blog reveals a counterintuitive truth, sometimes the path to faster sites is to ship more CSS. Not more bloat, of course, but more strategic CSS that eliminates runtime calculations, reduces layout shifts, and sidesteps expensive JavaScript.
In this guide, we explore how GitHub rethought their CSS delivery to dramatically improve site performance. We will unpack the architectural shifts, show you concrete code examples, and reveal how you can replicate these wins using tools like DivMagic, directly copying production-ready CSS from any website to prototype performance patterns instantly.
The Old Mindset: CSS as a Bottleneck
For years, performance audits screamed at us to “reduce unused CSS” and “minimize render-blocking resources.” Tools like PurifyCSS and UnCSS became standard. The assumption was simple: CSS blocks rendering, so smaller CSS = faster pages.
But GitHub’s engineering team noticed something. Their JavaScript bundles were growing to compensate for lean CSS, components imported inline styles, dynamic class names were computed at runtime, and layout shifts proliferated because dimensions weren’t declared until the browser parsed the JS.
The Hidden Costs of Minimal CSS
Consider this: a typical React component might use styled-components or CSS-in-JS to generate scoped styles. At runtime, the library parses template literals, injects <style> tags, and recalculates specificity. Each operation takes CPU time on the main thread.

GitHub found that by shipping more static CSS upfront, even if that meant larger initial bytes, they could eliminate hundreds of milliseconds of JavaScript execution during critical rendering paths. The browser’s CSS parser is incredibly fast. The JavaScript parser? Not so much.
How GitHub Optimized: Data-Driven CSS Architecture
The key insight from the GitHub Engineering Blog article is that performance optimization needs to be holistic. They measured not just bundle size, but total rendering time, layout stability (CLS), and Interaction to Next Paint (INP).

Precomputing Layouts with Static CSS
GitHub moved away from computing styles in JavaScript. Instead of letting a component calculate its own width based on props, they defined utility classes for every possible layout permutation.
/* Before (JS-dependent) */
.card {
width: calc(100% - var(--gutter) * 2);
margin-inline: var(--gutter);
}
/* After (precomputed static classes) */
.card--gutter-sm { width: calc(100% - 1rem); margin-inline: 0.5rem; }
.card--gutter-md { width: calc(100% - 2rem); margin-inline: 1rem; }
.card--gutter-lg { width: calc(100% - 3rem); margin-inline: 1.5rem; }
This change eliminated the need for custom properties to be computed at runtime. The browser could parse and apply the correct class immediately.
Embracing the Cascade for Theme Switching
Another bold move: GitHub shipped all theme variations (light, dark, and high-contrast) in a single CSS file, using the cascade to override colors based on a data attribute on <html>.
:root {
--bg: #ffffff;
--text: #1f2328;
}
[data-theme="dark"] {
--bg: #0d1117;
--text: #c9d1d9;
}
[data-theme="high-contrast"] {
--bg: #000000;
--text: #ffffff;
}
Traditional wisdom says: only load the theme the user needs. GitHub shipped them all. Why? Because the cost of an extra HTTP request or a JavaScript theme switch mechanism dwarfed the extra CSS bytes. The browser caches the entire stylesheet, and the theme toggle is instantaneous, a simple attribute change with zero JavaScript.
Beyond the Bytes: Why CSS is Cheaper Than You Think
The narrative that “CSS is cheap” needs nuance. A 500KB CSS file can increase First Contentful Paint (FCP) significantly if not optimized. But GitHub showed that structured, atomic CSS with high reuse is far more performant than a 150KB CSS file plus a 300KB JavaScript bundle that generates styles at runtime.
Critical vs Non-Critical CSS
GitHub didn’t just dump all CSS into one file. They split it into:
- Critical CSS (inlined in
<head>): above-the-fold styles. - Non-critical CSS (loaded asynchronously): everything else.
But the twist: their critical CSS was larger than before because they included layout precomputations and all theme variables. The non-critical CSS was smaller because it only contained rarely-used components.
<style>
/* Critical: includes layout classes, theme vars, typography */
</style>
<link rel="preload" href="/styles/non-critical.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
This approach meant the first paint included everything needed to render the page without layout shifts, even if the non-critical CSS hadn’t loaded yet.
The Role of DivMagic in CSS Performance Workflows
Now, how does this translate to your daily work? As a frontend developer, you can learn from GitHub’s patterns. But you don’t need to guess how they structured their CSS, you can use DivMagic, the browser extension that lets you copy any UI from any website.

Imagine inspecting a well-optimized page like GitHub’s, selecting a card component, and instantly copying its CSS, including its utility classes, precomputed layouts, and theme-aware variables. DivMagic extracts the exact styles used, giving you a ready-made foundation.
Practical Workflow with DivMagic
- Identify a performant UI pattern on a site like GitHub, Twitter, or Stripe.
- Use DivMagic to copy the element’s CSS, including all computed styles, pseudo-classes, and media queries.
- Paste into your project and adapt the class names to your naming convention.
- Test with Lighthouse to see if the pattern reduces CLS or INP.
This is not about copying blindly. It’s about learning from the best. When you see that GitHub uses grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)) instead of JavaScript-based masonry, you internalize a performance win.
Case Study: Reducing Cumulative Layout Shift (CLS)
GitHub’s navigation bar is a masterclass in preventing CLS. They know the exact height of the header before any CSS loads. How? They declare it in the critical CSS, with fallback values for the logo dimension.
.Header {
height: 64px;
display: flex;
align-items: center;
}
.Header-logo {
width: 32px;
height: 32px;
flex-shrink: 0;
}
Without these explicit dimensions, the browser would first render the header without the logo (since the image hasn’t loaded), then shift content when the logo appears. By shipping this CSS upfront, GitHub ensures the layout is stable from the first paint.
The Trade-offs: When More CSS Hurts
Of course, shipping more CSS blindly is a mistake. It’s about strategic CSS, styles that replace runtime computations. If you’re shipping CSS for components that never appear on the page, you’re just wasting bandwidth.

How GitHub Avoided Bloat
They employed a code-splitting-at-component-level approach with the help of tools like CSS Modules and PurgeCSS during build. Each page got only the classes it needed, but those classes were fully precomputed.

For example, the issue page on GitHub loads full markdown styling, while the repository page loads code-syntax themes. Neither loads the other’s CSS, but each one loads more CSS than it would if those styles were generated by JavaScript.
| Approach | Initial CSS size | JS runtime cost | LCP |
|---|---|---|---|
| CSS-in-JS (before) | 120KB | 180ms | 2.3s |
| Static CSS (after) | 160KB | 30ms | 1.4s |
| GitHub’s final approach | 145KB | 20ms | 1.2s |
The comparison is stark. A modest increase in CSS size yielded a massive drop in runtime cost and a faster LCP.
How to Start Shipping More CSS Today
You don’t have to work at GitHub’s scale to benefit from their approach. Here is a step-by-step plan:
Step 1: Profile Your Runtime Styles
Use Chrome DevTools Performance tab to record page load. Look at “Styles” recalculations. How much time is spent parsing CSS-in-JS or applying inline styles? That’s your target.
Step 2: Extract Common Patterns
Identify components that appear multiple times on a page (buttons, cards, lists). Move their styles from JS to a static CSS file (or CSS Modules).
Step 3: Precompute Layouts
For responsive grids, define explicit class names for each breakpoint instead of using calc() or clamp() with custom properties that depend on JavaScript to set their values.
Step 4: Use DivMagic to Learn from the Best
When you find a site with excellent Core Web Vitals, use DivMagic to inspect and copy their CSS approach. Ask yourself: “Did they precompute this layout? Do they declare dimensions upfront? How do they handle themes?”
The Future: CSS as a Performance Accelerator
As the Web Almanac 2025 shows, only 48% of mobile origins pass Core Web Vitals. The gap often comes from INP (Interaction to Next Paint), where JavaScript-heavy frameworks struggle. GitHub’s approach, leaning more on static CSS, is a direct countermeasure.
What’s Next?
Expect to see more frameworks adopt “resumable” CSS patterns, precomputing as much as possible at build time. The rise of Tailwind CSS (which generates all utility classes upfront) already hints at this direction. GitHub’s custom approach takes it further by including design tokens and theme variations in static CSS.
Conclusion
Shipping more CSS sounds like heresy to performance purists, but GitHub’s engineering team proved it works, when done with intention. The key takeaways:
- Replace runtime style generation with static precomputed classes.
- Declare dimensions explicitly to prevent layout shifts.
- Ship all theme variations, the cascade and cache make it cheap.
- Split critical and non-critical CSS, but err on the side of including more in critical if it replaces JS.
- Learn from production sites: use DivMagic to copy and analyze their CSS patterns.
The best CSS is the CSS that doesn’t need JavaScript to exist. Ship it, cache it, and let the browser do its job.
Your users, and your Core Web Vitals scores, will thank you.
