perf(scripts): replace window.innerWidth with matchMedia to avoid forced reflow#620
Open
shsteimer wants to merge 1 commit into
Open
perf(scripts): replace window.innerWidth with matchMedia to avoid forced reflow#620shsteimer wants to merge 1 commit into
shsteimer wants to merge 1 commit into
Conversation
…ced reflow window.innerWidth forces a layout reflow each time it is read. matchMedia reads from the pre-computed style state without triggering layout, eliminating the Lighthouse forced-reflow warning on the eager load path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
Commits
|
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
window.innerWidth >= 900withwindow.matchMedia('(min-width: 900px)').matchesin the eager load path ofscripts.jswindow.innerWidthforces a synchronous layout reflow;matchMediareads from the pre-computed style state and does notWhy
Lighthouse / Chrome DevTools flags
window.innerWidthas a forced-reflow source. See: https://developer.chrome.com/docs/performance/insights/forced-reflowWhile i'm not convinced it's a real problem, I can envision scenarios where it could be, and I see no downside to eliminating the warning.
Preview
https://avoid-forced-reflow--aem-boilerplate--adobe.aem.live
🤖 Generated with Claude Code