Skip to content
This repository has been archived by the owner on Oct 30, 2024. It is now read-only.

significantly improve render performance on nav hover #709

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

phryneas
Copy link
Member

@phryneas phryneas commented Jan 12, 2024

Currently, hovering a single link in the navigation triggers three renders, one of which rerenders pretty much every component on the page and can take over 250ms on some documentation pages.

Scrolling the navigation on those pages can freeze the browser for seconds.

This PR brings that down to one render of less than 25ms.

The main problem here is that none of the various context values were memoized, which meant that with every rerender of a context provider all the consumers would also rerender. This cascaded from the useConfigs indirectly used in PageLayout through all other contexts.

I've gone ahead and memoized all of them - some were rather small performance gains, but it's impossible to say if that might change in the future, so better safe than sorry.

@phryneas phryneas requested a review from a team as a code owner January 12, 2024 12:28
Copy link

netlify bot commented Jan 12, 2024

Deploy Preview for apollo-monodocs ready!

Name Link
🔨 Latest commit 44398e2
🔍 Latest deploy log https://app.netlify.com/sites/apollo-monodocs/deploys/65a130543491740008d42d1e
😎 Deploy Preview https://deploy-preview-709--apollo-monodocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 48 (🔴 down 24 from production)
Accessibility: 85 (no change from production)
Best Practices: 92 (no change from production)
SEO: 95 (🟢 up 8 from production)
PWA: 50 (🟢 up 10 from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@phryneas
Copy link
Member Author

before: image
after:
image

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

Successfully merging this pull request may close these issues.

1 participant