The Unfinished Business of CSS Optimization: Revisiting the UDJO Principle

Main page › Web Development & UX › The Unfinished Business of CSS…
From ZizzMedia, the free news encyclopedia
The Unfinished Business of CSS Optimization: Revisiting the UDJO Principle
The Unfinished Business of CSS Optimization: Revisiting the UDJO Principle
Published: 18 November 2026
Author: Nana Wu
Category: Web Development & UX
Read time: 7 min read
Words: 1,278

Executive Overview

In the modern era of web development, where performance budgets are measured in milliseconds and every kilobyte counts toward a better Core Web Vitals score, we often lean heavily on automated tooling. Minifiers, post-processors, and bundlers have become the silent guardians of our codebase, stripping away whitespace and compressing assets with ruthless efficiency. Yet, there is a lingering, often overlooked aspect of CSS architecture: the structural repetition of declarations.

CSS optimization is a deceptively complex topic. While we have mastered the art of minification—the process of shrinking code for machine consumption—we have arguably grown complacent regarding the actual composition of our stylesheets. We assume that because our tools are advanced, our code must be optimal. This is a dangerous assumption.

This article explores the enduring relevance of "Using Declarations Just Once" (UDJO), a technique rooted in the fundamental DRY (Don’t Repeat Yourself) principle. By analyzing modern web traffic and utilizing new, purpose-built diagnostic tools, we challenge the notion that CSS optimization has hit a ceiling. As it turns out, the "de-duplication" of CSS declarations is not just a relic of early web standards; it is a viable, low-cost performance vector for the modern developer.


Detailed Chronology: From DRY Principles to Modern Complexity

The concept of UDJO is not new; its roots extend back at least 18 years, surfacing in an era when bandwidth was expensive and the CSS specification was far less robust than it is today. At its core, UDJO is simple: if the declaration display: flex; appears in ten different rule sets, it should—ideally—be declared once in a shared selector group.

The Philosophical Shift

In the early 2000s, the drive for DRY code was primarily motivated by file size constraints. Today, the motivation has evolved. While file size remains critical, we now weigh it against the maintainability of complex, component-based architectures. When we consolidate selectors, we aren’t just saving bytes; we are creating a "single source of truth" for specific UI patterns.

However, the "golden age" of manual CSS organization gave way to the rise of CSS-in-JS and utility-first frameworks like Tailwind. These paradigms, while revolutionary, often prioritize developer velocity over the raw efficiency of the CSS cascade. Consequently, many modern stylesheets have become bloated with redundant declarations, a side effect of component-based abstraction that many developers have simply accepted as the "cost of doing business."


Supporting Context & Metrics: Putting UDJO to the Test

To determine whether UDJO remains a relevant optimization strategy in an age of HTTP/3 and Brotli compression, we must move beyond theory and look at empirical data. To facilitate this, the development of CSS Dedup—a diagnostic and refactoring utility—allows us to quantify the impact of safe deduplication across a diverse set of websites.

The Methodology

The experiment analyzed 20 diverse websites, ranging from government portals to non-profit organizations and individual developer blogs. The analysis focused on two metrics:

  1. The "Natural" UDJO Effect: A direct deduplication of declarations across external stylesheets.
  2. Aggressive Optimization with Savings: A focused approach where deduplication only occurs if it demonstrably results in a reduction of the final file size, while maintaining the integrity of the CSS cascade.

Data Findings: The Institutional Landscape

The results, outlined below, highlight a fascinating discrepancy between theoretical optimization and practical application.

Site UDJO Effect (External) Aggressive (Savings Only)
commission.europa.eu +64.9 KB (+6.4%) -51.9 KB (-5.1%)
die-linke.de +104.0 KB (+20.5%) -21.2 KB (-4.2%)
eff.org +120.8 KB (+27.7%) -8.5 KB (-2.0%)
globalsumudflotilla.org -17.0 KB (-6.5%) -18.7 KB (-7.2%)
oic-oci.org -6.3 KB (-4.0%) -9.3 KB (-6.0%)

Table 1: Data from institutional and large-scale websites.

The data indicates that indiscriminate deduplication can sometimes backfire, potentially increasing the file size due to the restructuring of selectors and the overhead of longer comma-separated lists. However, when applied with an "aggressive, savings-only" filter, the results are overwhelmingly positive. In almost every case, we see a reduction in payload size, proving that there is indeed "low-hanging fruit" in existing production CSS.

The Developer-Blog Cohort

Interestingly, when we examine the personal sites of prominent web professionals—individuals who typically author highly performant code—the results shift.

Site UDJO Effect (External) Aggressive (Savings Only)
joshwcomeau.com -2.7 KB (-3.8%) -5.0 KB (-7.2%)
sarasoueidan.com -2.9 KB (-7.3%) -4.5 KB (-11.1%)
lea.verou.me -0.4 KB (-1.4%) -0.6 KB (-2.3%)

Table 2: Data from personal developer blogs.

The data suggests a strong correlation between developer expertise and inherent CSS efficiency. These sites often benefit immediately from deduplication because their baseline CSS is already cleaner. However, even for these experts, there is still room to carve out an additional 2–11% in file size savings through automated UDJO.


Official Perspective: The Mechanics of the Cascade

It is vital to address the "Why" behind these numbers. CSS is not just a list of properties; it is a cascade. The order of declarations, the specificity of selectors, and the location of rules within the document all determine the final computed style.

When we deduplicate using CSS Dedup, we are fundamentally altering the selector structure. If a declaration is moved from a more specific rule to a shared, less specific one, we risk breaking the layout if the cascade was relying on that specificity.

This is why "safe" deduplication is the only viable path. A tool must be able to identify where a declaration can be safely hoisted without conflicting with the cascade order. When we achieve this, we aren’t just compressing code; we are cleaning the architecture. The performance gains—while sometimes modest—are constant and cumulative.


Future Outlook: Is the Ceiling Higher?

The prevailing sentiment in the industry is that we have "solved" CSS optimization. With Gzip and Brotli compression reducing text files by 70-90%, many developers argue that manual or even automated de-duplication is a waste of time.

This is a fallacious argument. Compression algorithms thrive on entropy reduction. By deduplicating your CSS—making it more repetitive and structured—you are actually providing the compression algorithm with a more predictable data stream, which can, in some instances, yield even better compression ratios.

Toward a New Standard of CSS Maintenance

The future of CSS optimization lies in the integration of these "linting-plus-optimization" tools into the CI/CD pipeline. Currently, we use style-lints to check for errors and coding standards, but we rarely use them to check for structural efficiency.

The path forward involves:

  1. Automated Audits: Integrating tools like CSS Dedup into build steps to flag excessive repetition.
  2. Refined Tooling: Moving from "blunt" tools that treat all declarations equally to "context-aware" tools that understand the difference between layout properties (like display or grid) and aesthetic properties (like color or border-radius).
  3. The Culture of Efficiency: Re-educating developers on the importance of CSS architecture, ensuring that our reliance on frameworks does not blind us to the underlying efficiency of the browser-native cascade.

Conclusion

UDJO is not a silver bullet, nor is it a revolutionary new invention. It is a time-tested principle that has been neglected in the rush toward faster, more automated development cycles. However, as our websites grow in complexity and our global audience continues to demand faster load times on increasingly diverse hardware, every byte reclaimed is a win.

We have not reached the ceiling of CSS optimization. In fact, by looking back at the fundamental principles of the language and applying modern, data-driven tooling, we are only just beginning to see how much more efficient our stylesheets can be. It is time to stop accepting bloated code as an inevitability and start treating CSS as the precision instrument it was always meant to be.

📁 Categories: Web Development & UX

Related News