Skip to main content
KadiCache
Browse 37 Docs Guides & Search

Local CSS & JavaScript Minification, SRI & Relative URL Safety

Compress local stylesheets and classic scripts into kadicache-assets with automatic relative url() rewriting, SRI integrity preservation, and location-dependent script skips.

Optimization/CssOptimizer.phpOptimization/JsOptimizer.phpOptimization/LocalAssetSource.phpOptimization/CspPolicy.php
WP Admin -> KadiCache -> CSS & JavaScript (CSS & Cloud RUCSS)
MODULE 14 · 2X RETINA
Cloud Remove Unused CSS (RUCSS) with inline cascade injection and independent stylesheet minification.2880×1840 WebP
Quick Summary · 30-Second Operational SpecSource-Verified Guide
WP Admin Path
WP Admin -> KadiCache -> CSS & JavaScript
Expected Outcome
Content-Addressed kadicache-assets · 0 File Combining Bugs
Key Marker / Engine
CssOptimizer.php | JsOptimizer.php | data-no-minify
  • Compresses local .css and .js assets into wp-content/kadicache-assets/ (CssOptimizer.php & JsOptimizer.php) without combining or reordering files, preserving HTTP/2 & HTTP/3 multiplexing.
  • Rewrites relative url(../fonts/icon.woff2) and @import paths inside minified stylesheets accurately so theme icons and backgrounds never 404.
  • Enforces strict safety gates (MAX_CSS / MAX_JS = 1 MB, MIN_SAVINGS = 32 bytes) and automatically skips Subresource Integrity (integrity="..."), ES modules (type="module"), nomodule, and location-dependent scripts (document.currentScript).
  • Includes built-in compatibility exclusions for external Elementor print stylesheets (/elementor/css/) and PDF Embedder worker bundles (/pdf-embedder/js/).

Why KadiCache Minifies Individual Files Instead of Concatenating Giant Bundles#

A decade ago under HTTP/1.1, WordPress optimization plugins concatenated 20 separate CSS and JavaScript files into one giant merged-all.js file to work around browser 6-connection limits. On modern HTTP/2 and HTTP/3 (QUIC) servers, concatenating CSS/JS files is an anti-pattern that causes three serious problems:

  1. Cache Invalidation Amplification: Changing one 2 KB plugin script changes the combined hash of the entire 900 KB mega-bundle, forcing repeat visitors to re-download all 20 libraries!
  2. strict mode, import() & Global Scope Collisions: Concatenating a file starting with "use strict"; ahead of legacy jQuery plugins—or merging scripts expecting their own document.currentScript.src directory—triggers SyntaxError and TypeError crashes.
  3. Broken Media Queries & @charset / @import Rules: Naive CSS concatenation places @import rules below standard selectors where browsers ignore them.

KadiCache Free Core (CssOptimizer.php & JsOptimizer.php) minifies each eligible local stylesheet and classic script individually—stripping comments, whitespace, and formatting bloat while keeping exact <head> / <body> execution order and parallel HTTP/2–HTTP/3 streaming intact.

FIG 01Configuring Minify JavaScript files alongside Defer and Delay execution strategies inside WP Admin -> KadiCache -> CSS & JavaScriptZoom 2x

Inside CssOptimizer.php & JsOptimizer.php: Automatic Production Guardrails#

Both minifiers run behind HookFreeTagProcessor with deterministic safety boundaries so turning on Minify CSS files and Minify JavaScript files never breaks modern WordPress features:

Safety BoundaryCssOptimizer.php (kadicache-assets/css/)JsOptimizer.php (kadicache-assets/js/<scope>/)
File Size & Savings GateMax 1 MB (MAX_CSS), requires >= 32 B savingsMax 1 MB (MAX_JS), requires >= 32 B savings
Pre-Minified DetectionSkips files where minification saves < 32 bytesSkips pre-minified bundles (*.min.js) saving CPU cycles
Subresource Integrity (SRI)Skips <link integrity="sha384-..."> automaticallySkips <script integrity="..."> & SRI-preloaded scripts
Modern Script / Link TypesSkips rel="alternate stylesheet" & disabled linksSkips ES type="module", nomodule, & consent-guarded tags
Relative Path & Location SafetyRewrites relative url(...) paths to canonical origin/CDNDetects document.currentScript / relative worker paths & skips (location-dependent)
CSP Header ValidationVerifies CspPolicy::allowsUrl('style', ...)Verifies CspPolicy::allowsUrl('script', ...)
Built-In Plugin DefaultsAuto-excludes dynamic /elementor/css/ external filesAuto-excludes /pdf-embedder/js/ worker directories
Commerce Checkout ProtectionAutomatically bypasses is_cart(), is_checkout(), is_account_page()Automatically bypasses is_cart(), is_checkout(), is_account_page()

Notice why KadiCache stores generated assets under wp-content/kadicache-assets/ rather than inside wp-content/cache/kadicache/: KadiCache’s private HTML page-cache storage uses hardened 0700 directory permissions so nobody can browse raw cache directories over HTTP, whereas kadicache-assets/ is a clean, publicly web-servable static directory compatible with Nginx, Apache, and pull-zone CDNs (CdnUrlRewriter.php).

Configuring Local Minify Exclusions & Developer Attributes#

Inside WP Admin -> KadiCache -> CSS & JavaScript, you have four granular ways to exclude any file or page from minification:

  1. Excluded CSS Files (minify_css_exclusions) & Excluded CSS Page Paths (minify_css_excluded_paths): Expand the drawers at the bottom of the CSS Delivery card and enter filename fragments (custom-legacy-grid.css) or URL path prefixes (/legacy-embed/*).
  2. Excluded JS Files (minify_js_exclusions) & Excluded JS Page Paths (minify_js_excluded_paths): Expand the drawers inside JavaScript Execution & Minification to skip specific .js paths.
  3. HTML Attribute Opt-Out (data-no-minify): Add data-no-minify to any <link rel="stylesheet"> or <script> tag in custom theme PHP code.
  4. WordPress PHP Filters (kadicache_minify_css_exclusions / kadicache_minify_js_exclusions): Register plugin-level exclusions programmatically when distributing a custom agency theme:
PHPProgrammatic Minify Exclusions in Theme or MU-Plugin
add_filter('kadicache_minify_css_exclusions', static function (array $exclusions): array {
    $exclusions[] = '/themes/agency-child/assets/css/print-invoice.css';
    return $exclusions;
});

add_filter('kadicache_minify_js_exclusions', static function (array $exclusions): array {
    $exclusions[] = '/plugins/bespoke-webgl-viewer/dist/';
    return $exclusions;
});

CDN Compatibility, Cache Busting & Disk Hygiene for kadicache-assets#

Understanding how KadiCache manages wp-content/kadicache-assets/ helps DevOps engineers configure Nginx, Apache, and CDN edge rules cleanly:

  • Automatic Version & Content Fingerprinting: Whenever a plugin or theme updates a source .css or .js file, KadiCache computes a fresh content-addressed filename automatically—so browsers and CDNs fetch the updated file immediately without serving stale assets, even when Cache-Control: public, max-age=31536000, immutable is active!
  • Multisite & Multilingual Domain Scoping: CssOptimizer.php and JsOptimizer.php scope generated asset URLs per site and active language domain (LanguageDomains::currentOriginUrl()) so cross-domain multilingual networks never encounter CORS mismatches.
  • Safe Cleanup on Purge & Uninstall: CacheMaintenance.php and UninstallFilesystem.php prune retired generated assets cleanly without ever touching wp-content/uploads/ or theme source directories.

Frequently Asked Operational Questions

Why doesn’t KadiCache combine all CSS or all JS files into one single file?
On HTTP/2 and HTTP/3 servers, browsers multiplex multiple small compressed assets over a single TCP/QUIC connection simultaneously. Keeping files separate prevents global cache busting when one plugin updates and avoids strict-mode, ES module, and CSS cascade bugs caused by concatenation.
Will Minify CSS break relative font or background icon URLs like url(../webfonts/fa-solid-900.woff2)?
No. CssOptimizer.php resolves and rewrites relative url(...) and @import paths against the original stylesheet’s directory (and syncs with your configured CDN URL if enabled) before publishing to kadicache-assets/css/.
Why does CssOptimizer exclude /elementor/css/ automatically when Elementor uses external print files?
Elementor already generates pre-minified per-post CSS files inside wp-content/uploads/elementor/css/ and regenerates them dynamically when widgets change. Skipping redundant re-minification of those pre-minified files keeps post updates fast and clean.
Does KadiCache re-minify files on every visitor request?
Never! Minified assets are written once atomically to disk under content-addressed filenames in wp-content/kadicache-assets/, and the resulting HTML is cached in Early Delivery—so repeat visitors trigger zero PHP minification CPU.
Can I disable minification on just one page without editing global file exclusions?
Yes. Open the page in Gutenberg or Classic Editor and check Disable: CSS minification or Disable: JavaScript minification under KadiCache · Page Optimization Rules.
Gergis — Lead Systems & Cache Architect
Principal WordPress & Cloud Edge Architect
E-E-A-T Source Verified

Creator of KadiCache’s Early PHP Drop-In, 7-Driver Object Cache Engine, Cloud Remove Unused CSS, and Zero-CLS Lazy Render pipeline.

apps/wordpress-plugin/src/Optimization/CssOptimizer.phpapps/wordpress-plugin/src/Optimization/JsOptimizer.phpapps/wordpress-plugin/src/Optimization/LocalAssetSource.phpapps/wordpress-plugin/src/Optimization/CspPolicy.php
Was this engineering guide helpful?