Conversation
added 2 commits
August 18, 2026 10:39
blog-cards.js, related-blogs.js, blog-rail-case-study.js, and event-cards.js all hardcoded loading="lazy"/eager=false for every card image regardless of position, deferring even the first card's image past first paint on category/author/listing pages where it's the LCP candidate. Only the first card of the first instance of each block on a page now loads eagerly - pages with multiple stacked instances (e.g. /blog's 5 blog-cards sections, /events' two event-cards grids) would otherwise eager-load one image per instance, wasting bandwidth/priority on below-the-fold images. Fixes #518
The existing decorate() tests never attach blocks to document.body, so the new isFirstOnPage check (document.querySelector(...) === block) was previously unexercised by the test suite.
5 tasks
|
usman-khalid
force-pushed
the
main
branch
2 times, most recently
from
August 19, 2026 18:21
40a49bf to
0a53fdd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #518:
blog-cards.js,related-blogs.js,blog-rail-case-study.js, andevent-cards.jsall hardcodedloading="lazy"/eager=falsefor every card image regardless of position — including the first card, which is the LCP candidate on the 16+ category/author/listing pages this issue identified (and/blogitself, which I confirmed has the same pattern — see comment on #518).Fix
Only the first card of the first instance of each block on a page now loads eagerly. This matters because several templates stack multiple instances of the same block on one page:
/bloghas 5 separateblog-cardssections/eventshas 2event-cardsgrids (.upcoming,.on-demand)Marking every instance's first card eager (the issue's literally-suggested fix) would eager-load one image per section — wasting bandwidth/priority on below-the-fold images and potentially delaying the actual LCP image. Instead,
decorate()checksdocument.querySelector('.block-name') === blockonce, synchronously, before any async work — this is safe because EDS delivers all section/block markup in the initial HTML; only JS decoration is staged, so every block instance already exists in the DOM by the time any of them starts decorating.related-blogs.js/blog-rail-case-study.jsaren't wired into any live content yet (confirmed via git history and content search), but had the identical hardcoded-lazy pattern per the issue's audit checklist — fixed for consistency/future-proofing.Verified
construction-study.jpgon/blog/guide) — confirmed via performance trace it's the same node, nowloading="eager"with "Load duration" collapsing from ~1.2s to ~6ms (image no longer discovered late)./blog(5 instances) and/events(2 instances) directly in-browser: exactly 1 eager image total on each page, matching the true first/LCP-position card.order/reordering — DOM order matches visual order, soi === 0is reliably the visually-first card.test/event-cards.test.js) for theisFirstOnPagebehavior — the existingdecorate()tests never attached blocks todocument.body, so this logic was previously unexercised by the suite.npm run lintclean;npx vitest run— same 11 pre-existing failures asmain(comparison-table, lead-form-config, testimonial-video/-split), unrelated to these files, no regressions.Preview
https://cwvfix--intuit-erp--aemsites.aem.page/blog/guide
Fixes #518