Mon. Nov 23rd, 2026

Revisiting UDJO: An 18-Year-Old CSS Optimization Technique’s Enduring Relevance and Impact on Modern Web Performance

CSS optimization, often perceived as a straightforward task largely handled by existing tooling, is in reality a deceptively complex and continuously evolving field. While minification and bundling have become standard practice, the notion that all possible avenues for CSS optimization have been fully exploited may be premature, especially for a language that introduces new features and best practices almost daily. Amidst this dynamic landscape, an optimization technique dating back at least 18 years, known as UDJO – "using declarations just once" – is re-emerging as a potent strategy for enhancing both stylesheet maintainability and web performance.

The Genesis of UDJO and the DRY Principle

At its core, UDJO is directly inspired by the fundamental software engineering principle of DRY, or "Don’t Repeat Yourself." The DRY principle advocates for reducing repetition of information of all kinds, ensuring that each piece of knowledge has a single, unambiguous, authoritative representation within a system. In the context of CSS, UDJO applies this by identifying and consolidating identical declaration blocks that appear multiple times across a stylesheet.

Consider a common scenario where display: flex; is applied to various elements across a website. Historically, developers might define this property individually for each selector:

.example 
  display: flex;


.sample 
  display: flex;

The UDJO technique proposes to refactor this redundancy into a single, unified rule:

.example,
.sample 
  display: flex;

This consolidation has a dual benefit: it reduces the overall file size of the CSS stylesheet by eliminating redundant characters, and more importantly, it centralizes control. If the display property needs to be changed (e.g., from flex to grid), the modification only needs to occur in one place, significantly improving maintainability and reducing the likelihood of inconsistencies or errors. The effectiveness of UDJO hinges on two primary factors: the intelligence of the deduplication process and the length of the selectors involved. An intelligent deduplication ensures that combining declarations does not inadvertently alter the cascade order or specificity, which could lead to unintended visual changes. Meanwhile, shorter, more concise selectors tend to yield greater file size savings when grouped.

The Dynamic Landscape of CSS: Challenges and Conventional Optimizations

The past two decades have witnessed an exponential growth in the complexity and sophistication of web design and development. Modern CSS is no longer a simple styling layer but a powerful, expressive language that supports advanced layouts (Flexbox, Grid), dynamic variables (CSS Custom Properties), responsive design patterns (media queries, container queries), and intricate animations. This evolution, while empowering developers, also introduces new challenges for optimization.

The adoption of component-based architectures, CSS-in-JS solutions, utility-first frameworks like Tailwind CSS, and preprocessors like Sass and Less, has reshaped how CSS is authored and managed. While these tools often aim to improve development efficiency and consistency, they can inadvertently contribute to stylesheet bloat or repetition if not managed carefully. For instance, component-driven development might lead to localized styles that, when bundled, contain redundant declarations across different components.

Standard CSS optimization practices typically include:

  • Minification: Removing whitespace, comments, and shortening property/value names.
  • Concatenation: Combining multiple CSS files into one to reduce HTTP requests.
  • Purging/Tree-shaking: Removing unused CSS rules (e.g., with PurgeCSS).
  • Critical CSS: Inlining essential styles for the initial viewport to improve perceived performance.
  • Lazy Loading: Deferring the loading of non-critical CSS.
  • Compression: Using server-side compression algorithms like Gzip or Brotli.

UDJO complements these techniques by addressing a different layer of optimization: structural redundancy at the declaration level before other optimizations like minification or compression take full effect.

Bridging the Gap: The Emergence of CSS Dedup

Despite its clear theoretical advantages, applying UDJO manually to large, complex stylesheets can be an arduous and time-consuming task. The sheer volume of declarations and the intricate interplay of selector specificity and cascade rules make manual deduplication prone to errors. Recognizing this significant hurdle, a new tooling solution, CSS Dedup, was developed to automate this process.

CSS Dedup is designed not only to identify declaration repetition but also to intelligently deduplicate what can be safely optimized without altering the visual rendering of a webpage. The tool’s documentation highlights its careful consideration of the CSS cascade, a critical aspect of how browsers determine which styles to apply when multiple rules conflict. Deduplication affects selector locations, which directly influences the cascade order.

To address the nuances of safe deduplication, CSS Dedup offers different modes. It distinguishes between "provably safe" deduplication, where the tool can guarantee no visual changes, and more "aggressive" deduplication which might require additional validation, particularly when the primary goal is file size reduction. The tool’s ability to navigate these complexities provides developers with a robust mechanism to implement UDJO without extensive manual intervention, making this historically niche technique accessible to a broader audience.

Empirical Findings: UDJO’s Impact on Diverse Websites

To assess UDJO’s contemporary relevance, an experiment was conducted using CSS Dedup on a batch of 20 diverse websites. The analysis focused on the potential file size changes under two scenarios: a "UDJO Effect" (using the -f flag for external stylesheets, representing a more conservative, potentially less aggressive deduplication) and an "Aggressive With Savings Only" approach (using -f -a -s flags, prioritizing file size reduction while still aiming for safe changes). The results, presented in the table below, offer compelling insights:

Site UDJO Effect (External Style Sheets) (-f) Aggressive With Savings Only (-f -a -s)
12371.cn +2.9 KB (+14.3%) -45 B (-0.2%)
ccc.de +0.8 KB (+2.2%) -0.1 KB (-0.3%)
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%)
diem25.org +40.5 KB (+10.7%) -4.4 KB (-1.2%)
eff.org +120.8 KB (+27.7%) -8.5 KB (-2.0%)
en.mfa.ir +58.7 KB (+5.1%) -51.2 KB (-4.5%)
euroveg.eu +78.8 KB (+9.3%) -12.4 KB (-1.5%)
globalsumudflotilla.org -17.0 KB (-6.5%) -18.7 KB (-7.2%)
gruene.de +1.6 KB (+1.1%) -0.7 KB (-0.5%)
icanw.org +5.5 KB (+2.9%) -3.5 KB (-1.8%)
laquadrature.net +14.0 KB (+4.2%) -3.0 KB (-0.9%)
middleeasteye.net +60.9 KB (+8.6%) -20.5 KB (-2.9%)
movimientosumar.es +98.8 KB (+13.6%) -5.0 KB (-0.7%)
nam.go.ug +84.5 KB (+9.2%) -53.9 KB (-5.9%)
oic-oci.org -6.3 KB (-4.0%) -9.3 KB (-6.0%)
podemos.info +23.2 KB (+5.5%) -6.0 KB (-1.4%)
taxmenow.eu +1.7 KB (+2.1%) -4.0 KB (-4.6%)
unrwa.org +87.4 KB (+13.2%) -4.8 KB (-0.7%)
veganeurope.eu +37.3 KB (+17.7%) -1.3 KB (-0.6%)

The data reveals a critical distinction between the two deduplication strategies. The -f option, representing a direct application of UDJO without prioritizing file size reduction, often led to an increase in file size for many sites. This counter-intuitive result can occur when combining multiple short selectors into a single, longer comma-separated selector string, which can sometimes consume more characters than the individual, repeated declarations. For instance, a, b, c display: flex; might be longer than a display: flex; b display: flex; c display: flex; if a, b, and c are very short.

However, when the "Aggressive With Savings Only" (-f -a -s) option was employed, a different pattern emerged. In almost all cases, this strategy resulted in file size savings, ranging from negligible bytes to significant reductions of over 50 KB (e.g., commission.europa.eu, en.mfa.ir, nam.go.ug). This demonstrates that UDJO, when intelligently applied with a focus on size reduction, is indeed effective in reducing the raw size of CSS files. The average saving across these 20 sites with the aggressive, savings-only approach was approximately -2.5% to -3.0%, with some sites seeing savings as high as -7.2%.

It is crucial to note that these values represent raw file size changes before further compression (e.g., Gzip or Brotli), which would typically be applied in a production environment. Moreover, these figures do not inherently speak to the "quality" of the CSS or definitively confirm improved maintainability without deeper context regarding selector length and the specific use cases of the declarations. Nevertheless, the consistent reduction in file size under the aggressive strategy strongly indicates UDJO’s potential as a low-cost performance optimization.

Specialized Analysis: UDJO’s Performance in the Web Development Community

To gain further insight, a separate analysis was conducted on ten websites maintained by web developers and professionals. The hypothesis was that professionals in the web development field might already employ more optimized CSS practices, potentially leading to different UDJO outcomes.

Site UDJO Effect (External Style Sheets) (-f) Aggressive With Savings Only (-f -a -s)
bram.us +19.6 KB (+7.3%) -4.2 KB (-1.6%)
ishadeed.com +4.2 KB (+11.4%) -0.2 KB (-0.5%)
joshwcomeau.com -2.7 KB (-3.8%) -5.0 KB (-7.2%)
kevinpowell.co +0.1 KB (+0.6%) -0.1 KB (-0.5%)
kizu.dev +1.0 KB (+1.7%) -0.1 KB (-0.2%)
lea.verou.me -0.4 KB (-1.4%) -0.6 KB (-2.3%)
miriamsuzanne.com -0.2 KB (-0.5%) -0.7 KB (-2.0%)
paul.kinlan.me +3.3 KB (+8.0%) -1.0 KB (-2.4%)
pawelgrzybek.com -0.5 KB (-2.7%) -0.7 KB (-4.3%)
sarasoueidan.com -2.9 KB (-7.3%) -4.5 KB (-11.1%)

Similar to the general websites, the direct -f application showed mixed results, with some sites experiencing increases and others modest reductions. However, the "Aggressive With Savings Only" strategy again yielded consistent file size reductions across almost all sites. The percentage savings on developer sites appeared generally comparable to, or in some cases even better than, the general websites. For example, sarasoueidan.com saw an impressive -11.1% reduction, and joshwcomeau.com achieved -7.2%.

This data suggests that even among web professionals, where one might expect highly optimized stylesheets, there remains a demonstrable opportunity for UDJO to deliver further file size savings. The hypothesis that web professionals might employ shorter, more modular selectors, which could make them more amenable to UDJO’s benefits, seems plausible given these results. This warrants further investigation with a larger sample size and a deeper analysis of selector structures.

Strategic Implications: Integrating UDJO into Modern Web Development Workflows

The findings unequivocally affirm that UDJO remains an effective and relevant CSS optimization technique in the modern web development landscape. Its dual benefits — improved maintainability and reduced file size — position it as a valuable addition to any comprehensive web performance strategy.

From a maintainability perspective, UDJO enforces the DRY principle by centralizing declaration definitions. This reduces cognitive load for developers, makes codebases easier to navigate, and minimizes the risk of introducing bugs when styles are updated. For large, complex applications with multiple developers, a consistent approach to deduplication can significantly streamline the development and maintenance lifecycle.

On the performance front, the demonstrated file size savings, particularly with the "aggressive with savings only" approach, are compelling. Even modest percentage reductions in raw CSS size can translate into faster load times, especially for users on slower networks or mobile devices. While subsequent compression layers like Gzip and Brotli will further reduce the transfer size, starting with a smaller, deduplicated file provides a better baseline for these algorithms to work with, potentially yielding even greater overall savings.

Integrating UDJO into existing development workflows can be achieved through automated tooling like CSS Dedup. This allows developers to incorporate deduplication into their build pipelines, ensuring that stylesheets are optimized automatically without manual intervention. It can be a step performed after CSS pre-processing (e.g., Sass compilation) and before minification, serving as a powerful pre-optimization stage.

The "intelligence" of the deduplication process is paramount. While tools can automate much of the work, understanding how specific declarations interact with the cascade and specificity rules is crucial. Developers may need to configure tools to exclude certain declarations or patterns from deduplication if they are intentionally repeated for specificity reasons or if they involve complex interactions that the tool cannot safely resolve. This collaborative approach, where developers understand the underlying principles and configure tools accordingly, will yield the best results.

Conclusion: The Enduring Value of Fundamental Optimization

The re-examination of UDJO demonstrates that even long-standing techniques can offer significant value in an ever-evolving technological environment. The data suggests that CSS stylesheets, even those from well-maintained and professionally developed websites, often contain declaration repetition that can be safely and effectively optimized.

For anyone committed to optimizing CSS for maintainability and performance, UDJO should be considered an integral part of their overall approach. The emergence of specialized tooling like CSS Dedup has democratized this technique, making it accessible and practical for real-world application. The journey of CSS optimization is clearly far from over; instead, it is an ongoing endeavor that benefits from revisiting fundamental principles with modern tools and analytical rigor. The findings presented here serve as an invitation to the web development community to review, test, and further explore this vector, affirming that the ceiling of what is achievable in CSS optimization has not yet been reached.

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *