In the world of front-end web development, CSS optimization occupies a surprisingly deceptive space. On the surface, reducing stylesheet overhead feels like a solved problem—a routine task handed off to automated minifiers, bundlers, and build pipelines. Yet assuming that the web development industry has exhausted every available venue for stylesheet optimization is naive, particularly for a styling language that undergoes continuous evolution.
While modern tooling routinely strips whitespace, comments, and redundant formatting, deeper structural optimizations are frequently overlooked. One such technique is "Using Declarations Just Once" (UDJO), a design and optimization philosophy that dates back at least 18 years. Inspired by the classic software engineering principle of "Don’t Repeat Yourself" (DRY), UDJO operates by systematically identifying and consolidating repeated CSS declarations across a stylesheet.
Despite its age, the technique raises an essential question for modern web performance engineers: Is UDJO still an effective and relevant optimization strategy in an era dominated by modern CSS frameworks, utility classes, and complex preprocessors? Recent research and automated benchmark testing reveal that while the technique requires careful handling regarding selector length and cascade management, automated declaration deduplication can still unlock tangible file size savings across high-traffic production websites.
The Mechanics of Declaration Deduplication
At its core, UDJO addresses the repetition of individual CSS key-value pairs across separate rulesets. In standard web development, identical styling declarations are often written repeatedly across different classes or components. For instance, two separate rulesets might independently define an identical layout model:
.example
display: flex;
.sample
display: flex;
Through declaration deduplication, these identical property-value pairs are reconciled into a single grouped ruleset:
.example,
.sample
display: flex;
While the concept is straightforward, its practical efficiency hinges on two main variables: deduplication intelligence and selector length. The intelligence of the deduplication process determines whether combining rules preserves original stylesheet specificity, cascade order, and code maintainability. Meanwhile, the physical length of the combined selectors heavily influences whether the refactoring actually reduces overall file size.
Combining selectors only saves bandwidth if the byte length of the added selector list is shorter than the combined byte count of the repeated declarations being eliminated. If complex, deeply nested, or unusually long selectors are grouped together to save a short declaration, the resulting ruleset can actually increase total file size rather than reduce it.
Manually auditing and refactoring complex enterprise stylesheets for declaration duplication is an extraordinarily labor-intensive process. To streamline this workflow and measure its real-world efficacy, developer tooling known as CSS Dedup was created. Designed to identify structural repetitions and execute safe deduplication, the tool factors in selector positioning and the rules of the W3C CSS Cascade specification to ensure that optimized stylesheets maintain their original visual presentation.
Is There Anything to Deduplicate in Modern CSS?
To evaluate the current state of stylesheet repetition on the live web, an initial empirical test was conducted across 20 arbitrarily selected websites representing public institutions, media outlets, and non-profit organizations. The analysis evaluated external stylesheets under two distinct automated execution configurations using the CSS Dedup tool:
- Standard Safe UDJO Mode (
-f): Applies standard, provably safe declaration deduplication across external stylesheets regardless of the resulting file size. - Aggressive Savings-Only Mode (
-f -a -s): Executes aggressive deduplication while strictly discarding changes unless they result in net file size reductions.
The findings from the initial 20-site benchmark demonstrated a clear contrast between naive structural deduplication and targeted size-focused optimization.
Under the default safe UDJO configuration, several large websites experienced file size increases due to the presence of extremely long selector strings. For example, the Electronic Frontier Foundation (eff.org) saw its external CSS footprint increase by 120.8 KB (+27.7%), moving from its baseline size when long selectors were repeatedly joined together. Similarly, the German political site die-linke.de expanded by 104.0 KB (+20.5%), the UN Relief and Works Agency site unrwa.org grew by 87.4 KB (+13.2%), and movimientosumar.es increased by 98.8 KB (+13.6%). Other sites showing growth under standard deduplication included nam.go.ug (+84.5 KB / +9.2%), euroveg.eu (+78.8 KB / +9.3%), middleeasteye.net (+60.9 KB / +8.6%), en.mfa.ir (+58.7 KB / +5.1%), diem25.org (+40.5 KB / +10.7%), veganeurope.eu (+37.3 KB / +17.7%), podemos.info (+23.2 KB / +5.5%), laquadrature.net (+14.0 KB / +4.2%), icanw.org (+5.5 KB / +2.9%), 12371.cn (+2.9 KB / +14.3%), taxmenow.eu (+1.7 KB / +2.1%), gruene.de (+1.6 KB / +1.1%), and ccc.de (+0.8 KB / +2.2%).
However, two sites in the baseline test achieved immediate size reductions even under the standard safe mode: globalsumudflotilla.org reduced its stylesheet burden by 17.0 KB (-6.5%), while oic-oci.org saved 6.3 KB (-4.0%).
The landscape shifted dramatically when applying the aggressive savings-only mode (-f -a -s). By instructing the tool to perform deduplication only when it yields byte-level efficiency, every single site in the benchmark registered a net reduction in CSS transfer size.
The largest absolute bandwidth savings occurred on major organizational portals. The official portal of the Non-Aligned Movement (nam.go.ug) trimmed its stylesheet overhead by 53.9 KB (-5.9%). The European Commission website (commission.europa.eu) achieved a reduction of 51.9 KB (-5.1%), while the Ministry of Foreign Affairs of Iran (en.mfa.ir) eliminated 51.2 KB (-4.5%). Significant reductions were also recorded for die-linke.de (-21.2 KB / -4.2%), middleeasteye.net (-20.5 KB / -2.9%), globalsumudflotilla.org (-18.7 KB / -7.2%), euroveg.eu (-12.4 KB / -1.5%), oic-oci.org (-9.3 KB / -6.0%), eff.org (-8.5 KB / -2.0%), podemos.info (-6.0 KB / -1.4%), movimientosumar.es (-5.0 KB / -0.7%), unrwa.org (-4.8 KB / -0.7%), diem25.org (-4.4 KB / -1.2%), taxmenow.eu (-4.0 KB / -4.6%), icanw.org (-3.5 KB / -1.8%), laquadrature.net (-3.0 KB / -0.9%), veganeurope.eu (-1.3 KB / -0.6%), gruene.de (-0.7 KB / -0.5%), ccc.de (-0.1 KB / -0.3%), and 12371.cn (-45 B / -0.2%).
These empirical results confirm that redundant declarations remain widespread across production web applications, offering measurable opportunities for post-processing optimization.
Comparative Performance Across Web Development Portfolios
To analyze whether authoring practices among web industry specialists influence CSS repetition, a second sample group comprising 10 personal websites belonging to prominent web developers and engineers was evaluated under the same parameters.
The results showed a noticeably higher degree of baseline optimization among web professionals, driven largely by shorter selector choices and leaner authoring patterns. Under the standard safe UDJO configuration (-f), four out of the ten developer sites achieved instant file size reductions without needing selective optimization filtering:
- sarasoueidan.com: Decreased by 2.9 KB (-7.3%)
- joshwcomeau.com: Decreased by 2.7 KB (-3.8%)
- pawelgrzybek.com: Decreased by 0.5 KB (-2.7%)
- lea.verou.me: Decreased by 0.4 KB (-1.4%)
- miriamsuzanne.com: Decreased by 0.2 KB (-0.5%)
The remaining professional developer sites experienced modest size increases under naive deduplication: bram.us (+19.6 KB / +7.3%), ishadeed.com (+4.2 KB / +11.4%), paul.kinlan.me (+3.3 KB / +8.0%), kizu.dev (+1.0 KB / +1.7%), and kevinpowell.co (+0.1 KB / +0.6%).
When evaluated under the aggressive savings-only mode (-f -a -s), all ten developer sites realized net performance gains:
- joshwcomeau.com: Reduced by 5.0 KB (-7.2%)
- sarasoueidan.com: Reduced by 4.5 KB (-11.1%)
- bram.us: Reduced by 4.2 KB (-1.6%)
- paul.kinlan.me: Reduced by 1.0 KB (-2.4%)
- pawelgrzybek.com: Reduced by 0.7 KB (-4.3%)
- miriamsuzanne.com: Reduced by 0.7 KB (-2.0%)
- lea.verou.me: Reduced by 0.6 KB (-2.3%)
- ishadeed.com: Reduced by 0.2 KB (-0.5%)
- kevinpowell.co: Reduced by 0.1 KB (-0.5%)
- kizu.dev: Reduced by 0.1 KB (-0.2%)
The higher frequency of natural size reductions in standard mode across developer sites suggests that modern front-end engineers who utilize concise, efficient CSS selectors allow declaration deduplication techniques like UDJO to operate with far greater natural efficiency.
On the Effectiveness of UDJO as a CSS Optimization Technique
The empirical data demonstrates that "Using Declarations Just Once" remains a highly effective performance optimization vector for modern web applications. However, its practical deployment relies heavily on how intelligent automated tools are when balancing selector lengths against repetitive properties.
Because unconstrained deduplication can inadvertently inflate asset sizes when joining long selectors, tooling must be configured to prioritize net file size savings. When paired with conditional build flags—such as filtering optimizations strictly for byte reduction—UDJO provides a low-cost, automated mechanism to squeeze further efficiency out of production stylesheets.
It is worth noting that these test metrics reflect raw, uncompressed file sizes. While modern HTTP compression algorithms like gzip and Brotli excel at compressing repeated text strings, reducing underlying uncompressed CSS payload sizes remains a fundamental performance best practice. Lower raw byte counts reduce memory consumption during CSS parsing and object model construction in the browser rendering engine.
Ultimately, declaration deduplication demonstrates that modern web development has not yet hit a absolute ceiling in stylesheet optimization. Integrating UDJO and DRY CSS concepts into modern build toolchains offers performance engineers a proven technique to reduce web bloat and refine front-end delivery.