CoreBoost v3.3.9
🔄 Reworked - cb-lcp Strategy: Preload-Only (Remove <img> Injection)
Root Cause Analysis
The <img> injection approach was based on a false premise. Elementor's video background
fallback image is applied as style="background: url(...) 50% 50%; background-size: cover;"
via server-side PHP (Group_Control_Background selectors). This means:
- The CSS background paints immediately without JS — it is not lazy-loaded or gated
on Elementor adding.e-lazyloaded. - The PSI "resource load delay" metric measures image discovery time, not paint-blocking
JS. The browser only discovers CSSbackground-imageURLs after downloading and parsing
the stylesheet — this is what causes the delay. - A
<link rel="preload" fetchpriority="high">in<head>is the direct and correct fix —
the preload scanner finds it during initial HTML tokenisation, before any CSS is fetched. - Injecting a
<img>as a child of the Elementor section was fighting Elementor's flex
layout unnecessarily, causing double-height sections on desktop and size/overlap issues
on mobile, with no benefit to the LCP metric.
Changes
inject_lcp_foreground_image()(Resource_Remover): removed<img>construction and
injection entirely. The function now only extracts the image URL (via the 4-level cascade)
and emits a<link rel="preload" as="image" fetchpriority="high">before</head>. The
section's opening tag is returned unmodified. No DOM changes, no layout impact.output_lcp_img_styles()(Hero_Optimizer): removed method andwp_headhook — no
<img>element exists to style.define_hooks(): removedoutput_lcp_img_stylesregistration.get_foreground_conversion_css():.cb-lcp-imgblock updated to note removal.
What Still Fires
preload_video_hero()atwp_headpriority 1 (via bothpreload_methoddispatch and the
unconditionalenable_lcp_foreground_injectionguard added in v3.3.7) — reads
_elementor_datafrom DB and emits the preload tag early.- Output-buffer preload fallback in
inject_lcp_foreground_image()— covers cases where
preload_video_hero()misses the URL (e.g. non-standard Elementor structures).
Files Modified
includes/public/class-resource-remover.php—inject_lcp_foreground_image()img injection removedincludes/public/class-hero-optimizer.php—output_lcp_img_styles()removed;define_hooks()updated