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

Performance: find wallets first render optimizations #13139

Merged
merged 4 commits into from
Jun 17, 2024

Conversation

pettinarip
Copy link
Member

@pettinarip pettinarip commented Jun 11, 2024

Description

Refactor the find wallet logic to optimize the first render.

Current dev
Task 1: 550ms
Task 2: 2.2s - 2.7s
Task 3: 1.4s

With optimizations
Task 1: 500ms
Task 2: 1.8s
Task 3: 1.2s

@github-actions github-actions bot added the tooling 🔧 Changes related to tooling of the project label Jun 11, 2024
Copy link

netlify bot commented Jun 11, 2024

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit 1b6bde3
🔍 Latest deploy log https://app.netlify.com/sites/ethereumorg/deploys/66708cad7b5ce40008fddf63
😎 Deploy Preview https://deploy-preview-13139--ethereumorg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
7 paths audited
Performance: 42 (🟢 up 4 from production)
Accessibility: 92 (no change from production)
Best Practices: 83 (🔴 down 9 from production)
SEO: 93 (no change from production)
PWA: -
View the detailed breakdown and full score reports

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

@@ -47,7 +43,6 @@ export const MobileFiltersMenu = ({
onClose,
}: MobileFiltersMenuProps) => {
const { t } = useTranslation("page-wallets-find-wallet")
const { filteredWallets } = useWalletTable({ filters, t, walletData })
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved this hook to the parent (page component) to share the results and minimize the calls we do for it since its doing the main filtering.

filteredWallets,
updateMoreInfo,
walletCardData,
} = useWalletTable({ filters, t, walletData })
Copy link
Member Author

Choose a reason for hiding this comment

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

As mentioned before, moved this to the parent.

@@ -232,6 +234,17 @@ const WalletTable = ({
})
}

const showMoreInfo = (wallet) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved this function creation outside of the .map loop.

@@ -120,20 +120,12 @@ export const useWalletTable = ({
},
]

const [walletCardData, setWalletData] = useState(
const [walletCardData, setWalletData] = useState(() =>
Copy link
Member Author

Choose a reason for hiding this comment

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

Use the initialized function to run this map only once.

return { ...wallet, moreInfo: false, key: wallet.name }
})
)
}, [walletData])
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed since walletData is not never going to change now that we build the list at build time. This reduces also one extra render that we had.

Copy link
Contributor

github-actions bot commented Jun 11, 2024

Page Performance Accessibility Best practices SEO PWA
/en/ 🟠 59 🟢 94 🟢 93 🟢 93 🔴 38
/en/wallets/find-wallet/ 🟠 52 🟠 88 🟢 93 🟢 93 🔴 38
/en/staking/ 🟠 60 🟢 91 🟢 93 🟢 93 🔴 38
/en/whitepaper/ 🔴 46 🟢 95 🟢 93 🟢 93 🔴 38
/en/nft/ 🟠 57 🟢 95 🟢 93 🟢 93 🔴 38
/en/developers/docs/intro-to-ethereum/ 🔴 49 🟢 94 🟢 93 🟢 93 🔴 38
/en/developers/tutorials/creating-a-wagmi-ui-for-your-contract/ 🟠 65 🟠 89 🟢 93 🟢 93 🔴 38

Lighthouse scores are calculated based on the latest audit results

}}
/>
{/* Use `Show` instead of `hideBelow` prop to avoid rendering the sidebar on mobile */}
<Show above="lg">
Copy link
Member Author

Choose a reason for hiding this comment

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

This will add a bit of CLS on the table section on desktop versions. I think it is worth it considering that we are removing this from the render of slower mobile devices.
image

Copy link
Member

Choose a reason for hiding this comment

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

Okay.. yeah, if we're preventing a large unnecessary chunk of data from loading then I think it's worth it.

Copy link
Member

@wackerow wackerow left a comment

Choose a reason for hiding this comment

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

Looks good, nice job @pettinarip!

@wackerow wackerow merged commit 40afdc0 into dev Jun 17, 2024
10 of 11 checks passed
@wackerow wackerow deleted the performance/find-wallets-optimizations branch June 17, 2024 20:51
This was referenced Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tooling 🔧 Changes related to tooling of the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants