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

pagespeed: supporters section causes forced reflow #981

Open
benmccann opened this issue Dec 11, 2024 · 7 comments
Open

pagespeed: supporters section causes forced reflow #981

benmccann opened this issue Dec 11, 2024 · 7 comments

Comments

@benmccann
Copy link
Member

This line is being flagged as expensive by Chrome devtools because it causes the page layout to be recalculated:

That class is used to do something on Macs. Not exactly sure what this is or why it's needed:

:global(.scrollbars-invisible) [aria-current='page']::after {

The .scrollbars-visible class is unused and can be removed

@Rich-Harris
Copy link
Member

Both are needed to render the arrow indicating the active section of the docs:

image

It shouldn't be causing a layout, it has position: absolute

@benmccann
Copy link
Member Author

Chrome says there's a "forced reflow" caused by the div.remove(); line:

Screenshot from 2024-12-10 18-26-14

Maybe it's a red herring though. If I remove that code I get basically the same thing, but without any line number reference. I'm not quite sure how to tell where it's coming from...

Screenshot from 2024-12-10 18-32-13

@Rich-Harris
Copy link
Member

What if you remove the line that sets the classname?

@benmccann
Copy link
Member Author

The latter was from removing the whole script block

@benmccann benmccann changed the title pagespeed: remove JS that causes layout recalculation to detect scrollbars pagespeed: supporters section causes forced reflow Dec 11, 2024
@benmccann
Copy link
Member Author

I figured out by deleting one section at a time from the homepage that it's coming from the CSS in the supporters section:

&:nth-child(n + 1):nth-child(-n + 12) {

@benmccann
Copy link
Member Author

Here's another clue that something is going on with the supporters section. If you look at the LCP, it happens in the middle of hydration, which is surprising. It should happen earlier on from the SSR'd content. If you follow the dotted line down to the very bottom and click on the last anonymous script block, it takes you to the supporters code.

Screenshot from 2024-12-11 15-52-23
Screenshot from 2024-12-11 15-52-38
Screenshot from 2024-12-11 15-52-51

@benmccann
Copy link
Member Author

I tried removing the Supporters section and deploying to a preview branch. It seemed to add a few points to the PageSpeed Insights score

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

No branches or pull requests

2 participants