这是indexloc提供的服务,不要输入任何密码
Skip to content

🚀 [Story performance] Fix CLS caused from AMP runtime CSS showing story before amp-story.css #37990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Apr 1, 2022

Conversation

mszylkowski
Copy link
Contributor

@mszylkowski mszylkowski commented Mar 31, 2022

On origin ampshared.css shows the document when v0.js is installed, but in many cases this happens in a different frame than amp-story.css being installed, meaning that for a split second the layout shows with just the ampshared.css styles and without amp-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 layoutCallback is completed).

dist/v0/amp-story-0.1.mjs: Δ -0.05KB
dist/v0/amp-story-1.0.mjs: Δ -0.05KB
dist/v0/amp-story-0.1.js: Δ -0.04KB
dist/v0/amp-story-1.0.js: Δ -0.04KB
dist/v0.js: Δ -0.06KB

@gmajoulet gmajoulet marked this pull request as ready for review March 31, 2022 18:42
@amp-owners-bot amp-owners-bot bot requested a review from alanorozco March 31, 2022 18:42
@amp-owners-bot
Copy link

Hey @gmajoulet, @newmuis! These files were changed:

extensions/amp-story/1.0/amp-story.css

1 similar comment
@amp-owners-bot
Copy link

Hey @gmajoulet, @newmuis! These files were changed:

extensions/amp-story/1.0/amp-story.css

@gmajoulet gmajoulet requested review from jridgewell and removed request for alanorozco March 31, 2022 18:42
@mszylkowski mszylkowski self-assigned this Mar 31, 2022
@mszylkowski
Copy link
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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants