Skip to content

Skip eager-loading hidden hero-marquee foreground at current breakpoint - #192

Open
JasonHowellSlavin wants to merge 1 commit into
stagefrom
performance-exploration
Open

Skip eager-loading hidden hero-marquee foreground at current breakpoint#192
JasonHowellSlavin wants to merge 1 commit into
stagefrom
performance-exploration

Conversation

@JasonHowellSlavin

Copy link
Copy Markdown

What

Guards the foreground fallback in getLCPImages so a hero-marquee foreground that is hidden at the active breakpoint (media-hidden-mobile / media-hidden-tablet) is never hinted as the LCP image.

Why

getLCPImages falls back to the foreground image when no breakpoint-specific background exists. If the foreground is hidden for the current viewport, that fallback could eager-load an image that is never rendered — wasting bandwidth and supplying a wrong fetchpriority hint.

How

const fgHidden = lcpSection.classList.contains('hero-marquee') && (
  (window.innerWidth < 600 && lcpSection.classList.contains('media-hidden-mobile'))
  || (window.innerWidth >= 600 && window.innerWidth < 1200 && lcpSection.classList.contains('media-hidden-tablet'))
);
const foregroundImg = fgHidden ? null : lcpSection.querySelector(':scope > div:last-child img');

Strictly narrowing — the existing breakpoint background paths are unchanged; only the hidden-foreground fallback now no-ops.

Context

Adopts the visibility-aware pattern from adobecom/cc#407, per discussion adobecom/milo-private#374. Breakpoint-aware background selection (cc#346) was already present; MEP marquee replacement (cc#345) does not apply to bacom (eager attributes are set before loadArea/MEP).

Test

  • Full unit suite passes locally (335 passed, 0 failed).
  • Validate on a hero-marquee page using media-hidden-mobile/media-hidden-tablet with no breakpoint background, across mobile/tablet/desktop.

🤖 Generated with Claude Code

getLCPImages falls back to the foreground image when no breakpoint-specific
background exists. When a hero-marquee hides its foreground via
media-hidden-mobile / media-hidden-tablet, that fallback could eager-load an
image that is not rendered at the active breakpoint. Guard the fallback so a
hidden foreground is never hinted as the LCP. Adopts the visibility-aware
pattern from adobecom/cc#407.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@aem-code-sync

aem-code-sync Bot commented Jun 25, 2026

Copy link
Copy Markdown

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
In case there are problems, just click a checkbox below to rerun the respective action.

  • Re-run all PSI checks
  • Re-run failed PSI checks
  • Re-sync branch
Commits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants