🚀 [Story performance] Fix CLS caused from AMP runtime CSS showing story before amp-story.css#37990
Merged
mszylkowski merged 23 commits intoampproject:mainfrom Apr 1, 2022
Merged
Conversation
gmajoulet
approved these changes
Mar 31, 2022
|
Hey @gmajoulet, @newmuis! These files were changed: |
1 similar comment
|
Hey @gmajoulet, @newmuis! These files were changed: |
jridgewell
approved these changes
Mar 31, 2022
Contributor
Author
|
There's been a regression of some unrelated unit tests that this PR caught, I'm fixing them on #37994 and then merging this PR (these unit tests are blocking this merge) |
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.
On origin
ampshared.cssshows the document when v0.js is installed, but in many cases this happens in a different frame thanamp-story.cssbeing installed, meaning that for a split second the layout shows with just theampshared.cssstyles and withoutamp-story.css. When this happens, the active page can change the size (especially for inline elements that take space) which causes CLS=1.TL;DR: If amp-story.css is not present, we don't want to show the story due to possible CLS. On cached docs the CSS is inlined so this won't affect anything, but on origin this prevents a flash of unstyled story.
Somewhat reverts back #37345 but shows the story earlier (CSS installation is earlier than
layoutCallbackis completed).