Skip to content
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

fix(v2): Fix announcementBar layout shifts #5040

Merged
merged 5 commits into from
Jun 24, 2021

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Jun 22, 2021

Motivation

Docusaurus announcement bar is appearing only after React hydration

It triggers a layout shift, which is a bad signal for SEO / Google / Core Web Vitals (cumulative layout shift metric)

Instead we can render the announcement bar on the server, and hide it immediately with inlined js if it has been dismissed

This removes completely the layout shift issue in core web vitals extension:

image

Have you read the Contributing Guidelines on pull requests?

yes

Test Plan

preview

@slorber slorber added the pr: bug fix This PR fixes a bug in a past release. label Jun 22, 2021
@slorber slorber requested a review from lex111 as a code owner June 22, 2021 17:16
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jun 22, 2021
@netlify
Copy link

netlify bot commented Jun 22, 2021

✔️ [V2]

🔨 Explore the source changes: 70059ab

🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/60d34b8e6fb6790008af804d

😎 Browse the preview: https://deploy-preview-5040--docusaurus-2.netlify.app

@github-actions
Copy link

github-actions bot commented Jun 22, 2021

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟢 Performance 91
🟢 Accessibility 98
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-5040--docusaurus-2.netlify.app/

@github-actions
Copy link

github-actions bot commented Jun 22, 2021

Size Change: +1.96 kB (0%)

Total Size: 571 kB

Filename Size Change
website/build/assets/css/styles.********.css 87.7 kB -119 B (0%)
website/build/assets/js/main.********.js 386 kB +871 B (0%)
website/build/blog/2017/12/14/introducing-docusaurus/index.html 66.4 kB +605 B (+1%)
website/build/index.html 31.1 kB +605 B (+2%)
ℹ️ View Unchanged
Filename Size
website/build/docs/introduction/index.html 235 B

compressed-size-action

Copy link
Contributor

@lex111 lex111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome job! 👏

@lex111
Copy link
Contributor

lex111 commented Jun 23, 2021

It also decides bug with height adjustment of sidebar menu. Apparently this regression after #4617 (just now noticed it).

image

@slorber
Copy link
Collaborator Author

slorber commented Jun 24, 2021

Thanks

It also decides bug with height adjustment of sidebar menu. Apparently this regression after #4617 (just now noticed it).

What do you mean by "decides bug"? is this fixed?

@lex111
Copy link
Contributor

lex111 commented Jun 24, 2021

Yes, this PR fixes that bug.

@slorber
Copy link
Collaborator Author

slorber commented Jun 24, 2021

great news then :) thanks

@slorber slorber merged commit 9916a0b into master Jun 24, 2021
@slorber slorber deleted the slorber/fix-announcement-bar-layout-shift branch August 17, 2021 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants