Step 1: Inventory of the CSS minification

Last modified by Lucas Charpentier on 2026/10/30 09:51

Step 1 of Replacement for the yuicompressor maven plugin. State of xwiki-platform master and xwiki-commons 18.10.0-SNAPSHOT, October 2026.

Summary

YUI Compressor minifies CSS through three paths:

  1. Build time, webjar packaging: the lifecycle defined in xwiki-commons runs the yuicompressor-maven-plugin on every module with this packaging, including contrib extensions.
  2. Build time, explicit: two platform modules declare the plugin, xwiki-platform-web-war and xwiki-platform-flamingo-skin-resources.
  3. Runtime: CssExtension minifies the output of every style sheet skin extension, CSS and LESS alike.

The change therefore spans xwiki-commons and xwiki-platform, and the replacement has to keep the .min.css naming and the aggregated bundles, which other code relies on.

Build time

Plugin management in xwiki-commons

The root pom of xwiki-commons manages net.alchim31.maven:yuicompressor-maven-plugin version 1.5.1:

  • includes **/*.css, excludes **/*.min.*;
  • output suffix .min, so foo.css becomes foo.min.css next to it;
  • skipped when xwiki.minification.skip is true. The xwiki-platform-core pom sets it to false by default, the debug profile turns it on.

The webjar packaging lifecycle

xwiki-commons-tool-webjar-handlers binds yuicompressor:compress to the compile phase of the webjar packaging, right after the two Closure Compiler executions for JavaScript. It:

  • minifies each CSS file of the webjar into a .min.css file;
  • aggregates all the .min.css files into webjar.bundle.min.css.

In xwiki-platform, 6 of the 14 webjar modules contain CSS, 8 source files in total:

ModuleCSS files
xwiki-platform-search-webjar2
xwiki-platform-wysiwyg-webjar2
xwiki-platform-tree-webjar1, plus CSS generated from LESS by the lesscss-maven-plugin
xwiki-platform-realtime-wysiwyg-webjar1
xwiki-platform-captcha-jcaptcha-webjar1
xwiki-platform-image-lightbox-webjar1

Their minified files are referenced directly, for example tree.min.css, searchSuggest.min.css or the webjar.bundle.min.css of the WYSIWYG webjar loaded by the macro wizard.

Outside xwiki-platform, a GitHub code search finds the webjar packaging in at least 6 xwiki-contrib repositories: ai-llm, application-interactive-link-visualizer, application-notification-word, draw.io, mxgraph and observation-websocket. They get the YUI minification through the same lifecycle.

Platform modules declaring the plugin

ModuleInputAggregationConsumer of the aggregation
xwiki-platform-web-war45 CSS files under resourcesresources/css/xwiki.bundle.min.css, from 5 files: modalPopup, jumpToPage, confirmationBox, notification, suggestjavascript.vm, loaded on every page through $xwiki.ssfx
xwiki-platform-flamingo-skin-resources11 CSS files under flamingoflamingo/css/converted.min.css, from every css/*.min.cssstyle.css, through #template

converted.min.css gathers the skin files converted from LESS to CSS, so this path grows as the LESS migration progresses.

Not concerned

  • JavaScript, minified by the Closure Compiler.
  • Modules built with the Node toolchain, for example xwiki-platform-node, Live Data, BlockNote, the notifications, web and realtime toolbar webjars, the design system webjar and xwiki-platform-bootstrap. They set xwiki.minification.skip to true and minify with their own tooling.
  • Third-party webjars, which ship their own .min.css files.

Runtime

  • CssExtension.getCompressor() wraps com.yahoo.platform.yui.compressor.CssCompressor. On an IOException it returns the source unminified. Broken output, as in XWIKI-21246, is not detected.
  • AbstractSxAction applies it to the whole response when DebugConfiguration.isMinify() is true, which is the default. The debug.minify configuration property disables it globally, the ?minify=false request parameter per request.
  • It covers:
    • style sheet extension objects with the CSS content type, parsed with Velocity or not;
    • style sheet extension objects with the LESS content type. less4j already compiles them with compression enabled, then YUI runs again on its output;
    • resources served by the ssx action from a JAR.
  • The dependency, com.yahoo.platform.yui:yuicompressor 2.4.8, is declared in xwiki-platform-skin-skinx. It embeds modified Rhino classes, which is why batik-js is excluded in the test ArtifactResolver and in the packager plugin PackageMojo. Those exclusions should be reviewed when YUI is removed.

The .min naming contract

When minification is enabled, XWiki.getSkinFile() looks for name.min.ext before name.ext. Templates also reference .min.css files and bundles by name. Whatever replaces the plugin must keep producing the same file names.

Volumes

PathCountRaw sizeGzipped
xwiki-platform-web-war resources45 files107 KB35 KB
xwiki-platform-flamingo-skin-resources11 files19.5 KB8.5 KB
webjar modules8 files12.8 KB5.1 KB
Style sheet extension objects in the XARs104 objects on 97 pages132 KB50 KB

The 104 objects split into 81 CSS objects, 44 of them parsed with Velocity, and 23 LESS objects, 3 of them parsed with Velocity.

What YUI buys us today

On the 64 build-time source files, YUI Compressor 2.4.8 reduces the size by 28%, both raw, 140 KB to 100 KB, and gzipped, 48.8 KB to 35.2 KB. That is 13.6 KB gzipped across all the build-time CSS.

Stripping comments alone already reduces the gzipped size by 22%: most of the gain comes from removing license headers. These figures are measured file by file on the sources, not on the aggregated bundles.

Consequences for step 2

  • The replacement must produce .min.css files next to their sources, support the aggregations (xwiki.bundle.min.css, converted.min.css, webjar.bundle.min.css) and honor xwiki.minification.skip.
  • The runtime engine must accept Velocity-generated CSS and less4j output, and fall back to the source when it cannot parse it.
  • The size gains at stake are small, so correctness on modern CSS should weigh more than the compression ratio.
  • The webjar packaging change in xwiki-commons also affects contrib extensions.

Get Connected