[MWPW-TBD] Optimize personalization module loading — eliminate serial fetch waterfall#6206
Closed
mokimo wants to merge 2 commits into
Closed
[MWPW-TBD] Optimize personalization module loading — eliminate serial fetch waterfall#6206mokimo wants to merge 2 commits into
mokimo wants to merge 2 commits into
Conversation
personalization.js, sanitizeHtml.js (static import), and promo-utils.js were loaded serially — each triggered only after the previous finished. On adobe.com/fr/creativecloud this created a ~130ms serial chain starting at t=499ms (personalization → +41ms sanitizeHtml → +44ms promo-utils). Adding modulepreload hints for all three in checkForPageMods(), before the getCountry() await, overlaps their fetches with country detection so the browser has them in the module cache by the time await import() fires. Verified locally: all three now start in parallel at the same timestamp. Also deduplicates the getConfig().base call in the same block. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…request sanitizeHtml.js had a single consumer (personalization.js) and was always loaded as a static import — meaning every page with personalization paid for an extra serial module fetch. Moving the logic directly into personalization.js eliminates that request entirely. - Inline stringToHTML, isPossiblyDangerous, sanitizeHtmlNode, and sanitizeHtmlBody into personalization.js as private functions (sanitizeHtmlBody exported for testability) - Delete libs/utils/sanitizeHtml.js - Remove the now-unnecessary modulepreload hint for sanitizeHtml.js - Update sanitizeHtml.test.js to import from personalization.js and drop the sanitizeHtml (firstChild) describe block — that export is gone Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Contributor
Author
|
Closed in favor of #6210 |
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.
Description
On pages with personalization enabled (e.g.
adobe.com/fr/creativecloud.html), the personalization module chain loaded fully serially:personalization.jssanitizeHtml.js(static import, discovered at parse)promo-utils.js(dynamic import fired ininit())~130ms of avoidable serial latency before personalization could apply changes to the DOM.
Fix 1 —
modulepreloadfor personalization deps (utils.js)Added
modulepreloadhints forpersonalization.jsand (when promo is enabled)promo-utils.jsincheckForPageMods(), placed before thegetCountry()await. Both fetches now start during country detection rather than after it, and are in the browser module cache by the timeawait import()fires.Fix 2 — Inline
sanitizeHtml.jsintopersonalization.jssanitizeHtml.jshad exactly one consumer (personalization.js) and was always required via a static import — making it a guaranteed serial fetch. Moving the logic directly intopersonalization.jseliminates the file and the extra request entirely.sanitizeHtmlBodyis exported frompersonalization.jsfor testability; the standalone file is deleted.Result: all three modules now start fetching in parallel.
To observe: DevTools → Network → filter JS → waterfall for
personalization.js/promo-utils.json any personalized page.Test URLs (milo branch vs main on the observed page):
Test URLs (milo standalone preview):
🤖 Generated with Claude Code
Before

Personalization -> sanitize-html -> promo-utils
After

Personalization+promo utils in parallel, inline always needed sanitizehtml