Skip to content

MWPW-206311: address #6643 review feedback - #6662

Merged
mokimo merged 2 commits into
vhargrave/lcp-blocks-only-pre-mepfrom
osahin/pr-6643-review-fixes
Sep 7, 2026
Merged

MWPW-206311: address #6643 review feedback#6662
mokimo merged 2 commits into
vhargrave/lcp-blocks-only-pre-mepfrom
osahin/pr-6643-review-fixes

Conversation

@mokimo

@mokimo mokimo commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Addresses review feedback from #6643, into that branch:

  • overmyheadandbody: missing crossorigin on the placeholders.json preload
    (as="fetch" preloads only get reused by a later same-URL fetch() call when
    crossorigin matches - otherwise the browser treats it as a mismatched
    resource and double-fetches, which is the "new additional request" the
    before/after comparison in MWPW-206311: preload first-section LCP content before MEP #6643 surfaced). Added, plus a test pinning it.
  • overmyheadandbody: dropped the unused catch (e) binding to match the
    no-op-catch convention used elsewhere in this same PR (getValidatedMasLibsUrl's
    own catch { ... }).
  • mokimo: anchored isCommerceBlock's merch alternative
    (/merch|^mas-/ -> /^merch|^mas-/) so a block whose name merely contains
    "merch" isn't misclassified as commerce. Harmless today, added a regression test.

Not changed (kept as-is, confirmed intentional - replied on both threads in #6643):

  • mokimo / zagi25's ?mep=off ordering question: preloadLcpCodeFiles() stays
    gated behind the existing if (mepParam === 'off') return;. When MEP is off there's
    no MEP/Target await to hide the preload behind, and the normal block-loading path
    already loads everything fast enough on its own - so this only needs to run when
    MEP is present, and adding the coupling isn't worth it.
  • zagi25's JSDoc-removal note on getValidatedMasLibsUrl - that JSDoc isn't new
    authorship, it's the pre-existing block (incl. its VULN-36379 security rationale)
    being relocated verbatim as part of this PR's reordering, and the neighboring
    getValidatedRepoOwnerOrigin-style validator elsewhere in the file keeps the same
    JSDoc convention.
  • mokimo's "approximate auto-block detector" comment suggestion - no new comments
    in libs/utils/utils.js, per this repo's convention for that file.

Verification: full Utils suite locally (215/215 passing, incl. 2 new tests for
the crossorigin fix and the isCommerceBlock anchor), ESLint clean. I intended to also
drive a live before/after comparison on the PR's own aem.page links via Playwright,
but couldn't get exclusive access to the browser instance in my environment - flagging
so nobody assumes that pass happened. Worth a manual before/after look before merge
given this touches a perf-sensitive path.

🤖 Generated with Claude Code

- add missing crossorigin to the placeholders.json preload link so the
  browser reuses it instead of double-fetching (overmyheadandbody)
- decouple preloadLcpCodeFiles() from ?mep=off - it preloads ordinary
  block/icon/placeholder resources, not MEP-specific ones, so only its
  own kill switch should gate it (mokimo, zagi25)
- anchor isCommerceBlock's merch alternative so a future block name
  containing "merch" as a substring isn't misclassified (mokimo)
- drop the unused catch binding to match the file's own convention
  (overmyheadandbody)
- note that the auto-block detector is intentionally approximate vs
  decorateAutoBlock (mokimo)
@aem-code-sync

aem-code-sync Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

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

  • Re-sync branch
Commits

- no comments in libs/utils/utils.js, per repo convention
- revert the preloadLcpCodeFiles()/mepParam==='off' ordering: when MEP is off
  there's no MEP/Target await to hide the preload behind, and the normal
  block-loading path already loads everything fast enough on its own, so this
  only needs to run when MEP is present
@mokimo
mokimo merged commit ece69a6 into vhargrave/lcp-blocks-only-pre-mep Sep 7, 2026
9 checks passed
@mokimo
mokimo deleted the osahin/pr-6643-review-fixes branch September 7, 2026 16:41
milo-pr-merge Bot pushed a commit that referenced this pull request Sep 9, 2026
* MWPW-206183: preload LCP-section blocks before MEP

Warm the first (LCP) section's assets — authored blocks, link-autoblocks,
placeholders, and icons.js — in loadArea immediately before the MEP await
in checkForPageMods() holds up section processing, so their fetches are
already in flight when processing resumes.

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

* MWPW-206311: preload first-section LCP content before MEP await

Warm the first section's block code, non-merch/mas autoblocks, placeholder sheets and icons during checkForPageMods() instead of after it, so the LCP element can paint sooner. fetchpriority=high; commerce (merch/mas) autoblocks excluded (heavy dep chain hurts non-store heroes).

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

* MWPW-206311: add disable-mep-perf-optimization metadata kill switch

Emergency opt-out: <meta name="disable-mep-perf-optimization" content="on"> skips the pre-MEP preload (page-level or site-wide via the global metadata sheet). Default = enabled.

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

* MWPW-206311: drop redundant fetchpriority; call preload from checkForPageMods

high == browser default for these preload types, so the explicit fetchpriority plumbing is removed (preloadBlockResources reverts to its original signature). The preload now fires inside checkForPageMods right after the mep=off early return, co-locating it with MEP logic while still running before the MEP await.

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

* MWPW-206311: unit test preloadLcpCodeFiles (kill switch, merch/mas exclusion)

Export preloadLcpCodeFiles and add focused tests: kill-switch metadata,
authored-block preload, non-commerce autoblock warming with merch/mas
excluded, media_*.mp4 video guard (anchor + img alt), placeholder and
icon gating, and the no-first-section early return.

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

* MWPW-206311: hoist mas-dep/preload chain above checkForPageMods

Move getValidatedMasLibsUrl, getMasDepUrl, STATIC_BLOCK_DEPS, blockDeps,
preloadBlockResources and preloadLcpCodeFiles above checkForPageMods so the
pre-MEP preloadLcpCodeFiles() call no longer needs an eslint-disable for
no-use-before-define. Pure reorder, no behavior change.

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

* MWPW-206313: warm geo-ip placeholder sheet in preloadLcpCodeFiles (pre-MEP)

#6589 hoisted geo-ip sheet warming into loadArea, but it runs after
`await checkForPageMods()` — i.e. behind the MEP/Target wait, the exact
latency this LCP work removes. Fold the same warmGeoIpSheet(config) call
into preloadLcpCodeFiles alongside the placeholder warms so a
{{...-geo-ip}} LCP token (or geo-ip-lcp MEP flag) is warmed before the
await. Idempotent via geoIpWarm[url] ??=, so loadArea's later call
dedupes. Geo-ip helpers hoisted above preloadLcpCodeFiles to keep it in
scope. Adds two tests (warms when lingo active + token; no-op otherwise).

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

* MWPW-206313: fold geo-ip lingo/token gate into warmGeoIpSheet

Both callers (preloadLcpCodeFiles and loadArea) repeated the same
lingoActive + -geo-ip-token + geo-ip-lcp gate. Move it inside
warmGeoIpSheet(config, section, isDoc) so each caller is a single line.

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

* MWPW-206311: also preload icons.css (rel=preload as=style) pre-MEP

loadLink's dedup selector is rel-aware (link[href][rel=stylesheet] for
loadStyle vs link[href] for preload), so the preload does not shadow the
rel=stylesheet that decorateIcons later appends -- both coexist and the
browser consumes the preload (single fetch). Warm the render-affecting
sheet in parallel alongside icons.js.

Tighten two decorateIcons tests to query the stylesheet specifically now
that a preload link with the same href also exists.

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

* MWPW-206311: exclude authored merch/mas blocks from pre-MEP preload too

The /merch|^mas-/ filter was applied only to link-derived autoblocks, so
an authored <div class="merch"> in the first section still pulled the
heavy commerce dep chain (commerce.js + autoblock.js) before MEP -- the
opposite of the change's intent. Apply the same exclusion to authored
blocks. Adds a test covering the authored-block path.

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

* MWPW-206311: warm (don't apply) block css pre-MEP; fix useBlockCode nala

preloadLcpCodeFiles ran preloadBlockResources before MEP, which applied the
DEFAULT block stylesheet via loadStyle. For a block MEP redirects with
useBlockCode (e.g. marquee -> libs/mep/sample-block-code/marquee, whose css
is `body { color: purple }`), the default blocks/marquee/marquee.css
(`.marquee { color: var(--color-white) }`, higher specificity) then overrode
the custom styling -> text rendered white, failing the cross-browser
mep-actions useBlockCode test.

Add a warmStyles option to preloadBlockResources: when set, css is warmed as
`rel=preload as=style` instead of applied via loadStyle. preloadLcpCodeFiles
now passes it, so the pre-MEP path only warms resources (nothing applied) and
decoration applies the correct (MEP-redirected) sheet post-MEP. Unit test
asserts the css is preloaded, not stylesheet-applied.

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

* MWPW-206311: drop explanatory comments from preload code/tests

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

* MWPW-206311: address #6643 review feedback (#6662)

* fix(perf): address review feedback on MWPW-206311 pre-MEP LCP preload

- add missing crossorigin to the placeholders.json preload link so the
  browser reuses it instead of double-fetching (overmyheadandbody)
- decouple preloadLcpCodeFiles() from ?mep=off - it preloads ordinary
  block/icon/placeholder resources, not MEP-specific ones, so only its
  own kill switch should gate it (mokimo, zagi25)
- anchor isCommerceBlock's merch alternative so a future block name
  containing "merch" as a substring isn't misclassified (mokimo)
- drop the unused catch binding to match the file's own convention
  (overmyheadandbody)
- note that the auto-block detector is intentionally approximate vs
  decorateAutoBlock (mokimo)

* fix(perf): drop added comments; keep mep=off short-circuit as-is

- no comments in libs/utils/utils.js, per repo convention
- revert the preloadLcpCodeFiles()/mepParam==='off' ordering: when MEP is off
  there's no MEP/Target await to hide the preload behind, and the normal
  block-loading path already loads everything fast enough on its own, so this
  only needs to run when MEP is present

* MWPW-206311: drop getValidatedMasLibsUrl JSDoc, no comments in utils (#6663)

fix(perf): drop JSDoc on getValidatedMasLibsUrl, no replacement comment

zagi25 flagged this JSDoc as inconsistent with the rest of the PR (#6643).
It was pre-existing code being relocated, not new authorship, but per repo
convention libs/utils/utils.js carries no comments - dropping it outright
rather than converting to a plain comment.

---------

Co-authored-by: Victor Hargrave <hargrave@adobe.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Okan Sahin <39759830+mokimo@users.noreply.github.com>
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.

1 participant