Skip to content

fix(rules): perf/lcp-hints stops flagging eager images below a preloaded hero #1221 - #1223

Merged
nc9 merged 2 commits into
mainfrom
fix/lcp-hints-one-preload-1221
Oct 28, 2026
Merged

nc9 merged 2 commits into
mainfrom
fix/lcp-hints-one-preload-1221

Conversation

@nc9

@nc9 nc9 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Closes #1221.

A page has one LCP element. Any preloaded candidate (of the first three eligible images) now satisfies lcp-preload; with no image preload it warns once, Likely-LCP image loaded without preload, naming the first candidate (value 1). findLcpCandidates is unchanged, so perf/lcp-fetchpriority is untouched. largeImagesWithoutPreload keeps its type and now holds at most one entry; its only consumer is this rule. Preload matching is unchanged (href, any imagesrcset URL, media attribute).

Tests: reporter fixture (preloaded hero + 4 eager 300x300 cards) passes with no candidates; a later preloaded candidate passes; no preload warns once naming the first; imagesrcset + media preload; lazy-cards control; fetchpriority parity. The tests that pinned the per-image count are updated. Docs: docs/rules/perf/lcp-hints.mdx, regenerated glossary/hub blocks, CHANGELOG. Gates: scripts/test-suites.ts --run rules (8040 pass; two timing tests, h1-title-alignment-929 and a11y-nesting-parity-3066, failed under machine load and pass by path), rules/core-contracts/CLI typecheck, CLI lint/format, make validate. template-invariance-measured.json needed no change (suite green on it).

The squirrelscan agent skill needs no change.

@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Review of #1223: the change is correct and I found nothing that should block merging. I did not run the tests or the checks; I read the diff and grepped for other users of largeImagesWithoutPreload.

  • (low) docs/rules/perf/lcp-hints.mdx:98 still says "Each page reports how many likely-LCP images went unpreloaded". The rule no longer reports a count, so please reword it.
  • (low) packages/report/tests/lcp-preload-grouping-1074.test.ts:26 and :38 use the old message 1 likely-LCP image loaded without preload as fixtures. They are only grouping fixtures, so they still pass. Still, update them to the new message so stored-report fixtures match what the rule now emits. Reports stored by older versions will keep the old message, which is fine as long as the grouping does not depend on the text.
  • (nit) packages/rules/src/performance/cwv.ts:334 is over the formatter's line width. CI does not format packages/*, so this is not a gate, but you could wrap the if condition.
  • (nit) value: n in lcp-hints.ts is now always 1 and n is derived from an array of at most one entry. That is harmless, but a comment or a literal would make the intent clearer.

Test coverage looks good: the reporter fixture, a later preloaded candidate, the media and imagesrcset preload cases, the lazy-cards control and lcp-fetchpriority parity are all covered.

@nc9

nc9 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Round 1: all four addressed (docs line, grouping fixtures, wrapped condition, value comment).

@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Review of #1223: the change is correct and I found nothing that should block merging.

  • (nit) packages/rules/src/performance/cwv.ts: the anyPreloaded line is over 100 columns. packages/rules isn't format-checked in CI, but run oxfmt on just this file if you want it tidy. The long reason string in lcp-hints.ts is the same.
  • (nit) largeImagesWithoutPreload is still typed string[] in core-contracts and apps/cli/src/types.ts, but it now holds at most one entry. The PR description says so, but a short comment on the field would help the next reader. lcp-hints.ts also assigns n to value where a literal 1 is clearer.
  • (low) The message no longer has a count. Anything that matched the old N likely-LCP images text, such as saved baselines or downstream dashboards, will now see a different string. The grep found no in-repo users beyond the updated tests, and the CHANGELOG entry covers the change.

I only read the diff and grepped for other uses. I didn't run the tests.

Tests are good: the reporter fixture, a later preloaded candidate, imagesrcset and media preloads, a lazy control and fetchpriority parity are all covered. The docs and CHANGELOG are updated.

nc9 added 2 commits October 29, 2026 00:25
…ded hero; one image named when none is preloaded #1221

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the fix/lcp-hints-one-preload-1221 branch from a4e03c3 to 948501d Compare October 28, 2026 13:25
@claude

claude Bot commented Oct 28, 2026

Copy link
Copy Markdown

Reviewed the diff. The logic change in cwv.ts and lcp-hints.ts matches the stated intent: any preloaded candidate among the first three satisfies the check, and otherwise only the first candidate is reported. findLcpCandidates is untouched, so perf/lcp-fetchpriority is unaffected. I found nothing that should block merge.

  • (low) packages/rules/src/performance/cwv.ts: largeImagesWithoutPreload is still typed string[] (packages/core-contracts/src/index.ts:2573) but now holds at most one entry, and lcp-hints.ts still derives n from its length. This is fine and avoids a contract change. A short comment on the type would stop a future reader from assuming it is a list.
  • (low) The message dropped its count, so any grouping or dashboards keyed on the old N likely-LCP images... text change. I grepped the repo and found no other consumers. Stored historical reports will still carry the old strings, which is expected.
  • (nit) The anyPreloaded line in cwv.ts is about 96 characters. packages/* is not formatted in CI, so this is harmless.

Test coverage is good: the reporter fixture, a later preloaded candidate, an imagesrcset or media preload, the lazy-cards control and fetchpriority parity are all covered. I did not run the tests myself.

@nc9
nc9 merged commit 6a3d779 into main Oct 28, 2026
15 checks passed
@nc9
nc9 deleted the fix/lcp-hints-one-preload-1221 branch October 28, 2026 13:40
nc9 added a commit that referenced this pull request Oct 29, 2026
…er the tags (#1248)

Restores the released v0.0.139 and v0.0.138 CHANGELOG sections byte-for-byte from their tags and puts the bullets of #1215, #1222, #1223 and #1190, deduplicated, under Unreleased. The guard against this is tracked in #1234. Docs: CHANGELOG only. Skill: no change.
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.

perf/lcp-hints: eager product-card images below a preloaded hero are counted as likely-LCP without preload

1 participant