- Eliminates the classic Delay JS visual breakage problem (stacked carousel slides,
opacity: 0entrance animations, frozen preloaders, and collapsed0pxad slots) automatically with zero manual CSS rules. - Measures real pre- vs post-Delay DOM geometry directly inside real visitor browsers (Desktop >=768px and Mobile <=767px) via HMAC-signed
POST /wp-json/kadicache-pro/v1/browser-hints. - Generates pure-geometry CSS locks (
carousel,reveal,hide,height) in<style id="kadicache-local-delay-css" data-kadicache-layout-tier="2">and patches cached HTML in place with 0 cache purges. - Removes lock CSS cleanly via
delay.jstier-2 handoff the moment delayed scripts initialize, and is toggleable from WP Admin, KadiCache Pulse (pro_delay_locks_enabled), and AI MCP (delay_locks).
Table of Contents (4 sections)
Why Standard Delay JavaScript Breaks Carousels, Animations & Preloaders#
Enabling Delay JavaScript Until Interaction is the fastest way to slash mobile Total Blocking Time (TBT) toward 0 ms. Yet on real WordPress and WooCommerce sites built with Elementor, WPBakery, Divi, Avada, or custom themes, holding JavaScript until first scroll or tap exposes four recurring visual defects at initial 0 ms paint:
- Stacked Vertical Carousels: Before Slick, Swiper, Owl Carousel, Splide, or Flickity scripts run, a 4-column horizontal product row stacks all 6 or 12 slides vertically in raw HTML, inflating initial page height and causing a massive layout jump when the visitor touches the screen.
- Invisible Entrance Animations (
opacity: 0): Headlines, hero cards, and GSAP/AOS/Salient reveal blocks wait for an intersection or scroll script to flipopacity: 1andtransform: none, leaving blank white gaps above the fold. - Stuck Loading Spinners & Page Preloaders: Overlays and
.loading-spinindicators remain visible until a delayed script hides them. - Collapsed
0pxWidget & Ad Slots: Flex containers whose height is calculated by JavaScript start at0px, then shove surrounding content downward once scripts wake up.
Self-Healing Delay JS (kadicache_pro_local_delay_locks) solves all four defects generically from pure DOM geometry—without maintaining fragile theme or plugin class blocklists, and without consuming Cloud Pro worker quota.
How the 4 Universal Pure-Geometry Lock Kinds Work#
On the first real visitor visit for an unlearned URL (separately for Desktop and Mobile), local-vitals-beacon.js snapshots candidate container geometry before delayed scripts execute and again after delayed scripts finish hydrating, then posts a compact HMAC-SHA256 signed payload to POST /wp-json/kadicache-pro/v1/browser-hints (rejecting bots, HeadlessChrome, Lighthouse, and cross-origin requests):
| Lock Kind | Pre-Delay Visual Defect Observed | Pure-CSS Lock Applied at 0 ms (kadicache-local-delay-css) | Automatic Release |
|---|---|---|---|
carousel | Uninitialized multi-slide or single-slide slider stacking cards vertically or hiding slides | Locks container into exact N-column CSS Grid (repeat(N, minmax(0, 1fr))), suppresses ::before/::after clearfix column theft, and hides overflow slides (:nth-child(n+N+1)) | Removed on delay.js tier-2 handoff |
reveal | Hero heading, card, or GSAP/AOS block stuck at opacity: 0, visibility: hidden, or off-position transform | Forces opacity: 1 !important; visibility: visible !important (and transform: none !important when translated/scaled) at 0 ms | Removed cleanly once script applies final class |
hide | Preloader overlay or in-container spinner visible pre-JS that disappears post-JS | Applies display: none !important at 0 ms while strictly skipping off-screen mobile drawers and navigation menus | Removed automatically on hydration |
height | Collapsed 0px banner/widget slot that expands after delayed JS runs | Reserves exact measured post-JS min-height to prevent vertical CLS jump | Released once script populates height |
Zero-Churn In-Place Patching & Shared-HTML Responsive Support#
- Zero Cache Purges (
BrowserHintsEndpoint::applyHintsInPlace()): When the first real Desktop or Mobile visitor submits learned locks, KadiCache patches the existing cached HTML file on disk atomically viakadicache_patch_cached_htmlwithout triggering a cache rebuild storm. - Shared HTML (
@media) Ready: Sites running Cloudflare Free Edge Cache withSeparate Mobile Cachedisabled still learn Desktop (>=768px) and Mobile (<=767px) column counts independently—emitting a single responsive<style id="kadicache-local-delay-css">block with separate breakpoints (e.g., 4 columns on desktop, 2 columns on mobile). - Survives Cache Clears: Learned geometric rows live in
wp_kadicache_pro_browser_hints(delay_json) and persist across full cache purges, resetting automatically only when you switch themes, update a post, or click Reset learned data. - Zero Stuck Locks & Guarded Edge Cases: Automated Chromium regression tests (
tests/unit/pro-local-vitals.mjs) and a 1,618-site / 3,236-run Desktop + Mobile real-browser benchmark verified 0 stuck locks and 0 JS console errors, with strict guards protecting off-screen mobile drawers, hover mega-menus,::beforeclearfix rows, anddisplay: nonemodal ancestors.
Honest Boundaries: What Still Belongs to Delay Exclusions & Improve LCP#
Self-Healing Delay JS is engineered for geometric and visibility stabilization of elements already present in server HTML. Two cases intentionally remain handled by dedicated KadiCache tools:
- Hero images using JS-only
data-srclazy-loading: Pair Self-Healing Delay JS with Pro Local Improve LCP, which de-lazies real above-the-fold hero images and injects responsivefetchpriority="high"preloads directly in HTML. - Interactive JS-rendered calculators or remote widgets: If a widget has zero HTML before its script fetches remote data and must be interactive at
0 ms, add its script handle to Delay JavaScript Exclusions (delay_js_exclusions) or tag it withdata-kadicache-no-delay.
Follow the step-by-step setup and verification walkthrough in the Self-Healing Delay JS Documentation Guide.
Creator of KadiCache’s Early PHP Drop-In, 7-Driver Object Cache Engine, Cloud Remove Unused CSS, and Zero-CLS Lazy Render pipeline.