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

AV-1153: Fix prefetching and hydration #570

Merged
merged 9 commits into from
Sep 27, 2024

Conversation

jakecoble
Copy link
Collaborator

@jakecoble jakecoble commented Aug 16, 2024

Copy link

vercel bot commented Aug 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
audioverse-next ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 27, 2024 3:57pm

Copy link

github-actions bot commented Aug 16, 2024

Localization Summary

language unchanged added removed untranslated
br 874 0 0 74
de 874 0 0 407
en 874 0 0 0
es 874 0 0 398
fr 874 0 0 415
ja 874 0 0 378
ru 874 0 0 388
zh 874 0 0 377

View full summary

Copy link

github-actions bot commented Aug 16, 2024

📦 Next.js Bundle Analysis for audioverse-next

This analysis was generated by the Next.js Bundle Analysis action. 🤖

🎉 Global Bundle Size Decreased

Page Size (compressed)
global 243.69 KB (-21 B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Nineteen Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load % of Budget (225 KB)
/[language]/account 21.4 KB 265.09 KB 117.82% (🟢 -0.05%)
/[language]/account/login 17.21 KB 260.9 KB 115.96% (🟢 -0.06%)
/[language]/account/register 18.01 KB 261.7 KB 116.31% (🟢 -0.04%)
/[language]/bibles/[id]/[book]/[chapter] 14.95 KB 258.64 KB 114.95% (🟢 -0.02%)
/[language]/bibles/chapters/[id]/[[...slugs]] 19.87 KB 263.55 KB 117.14% (🟢 -0.03%)
/[language]/books/tracks/[id]/[[...slugs]] 20.66 KB 264.35 KB 117.49% (🟢 -0.03%)
/[language]/discover 8.94 KB 252.63 KB 112.28% (🟢 -0.05%)
/[language]/embed/media/[id] 12.76 KB 256.45 KB 113.98% (🟢 -0.03%)
/[language]/library 22.2 KB 265.89 KB 118.17% (🟢 -0.05%)
/[language]/library/history 23.26 KB 266.95 KB 118.64% (🟢 -0.04%)
/[language]/library/playlists 23.29 KB 266.97 KB 118.66% (🟢 -0.05%)
/[language]/library/playlists/[playlist] 5.56 KB 249.25 KB 110.78% (🟢 -0.01%)
/[language]/library/playlists/[playlist]/items/[id]/[[...slugs]] 20.88 KB 264.57 KB 117.58% (🟢 -0.02%)
/[language]/playlists/[playlist]/items/[id]/[[...slugs]] 20.87 KB 264.56 KB 117.58% (🟢 -0.02%)
/[language]/songs/[id]/[[...slugs]] 20.65 KB 264.34 KB 117.49% (🟢 -0.03%)
/[language]/songs/book/[book]/[id]/[[...slugs]] 20.81 KB 264.5 KB 117.56% (🟢 -0.03%)
/[language]/sponsors/all 2.38 KB 246.07 KB 109.36% (🟡 +0.03%)
/[language]/stories/[id]/[[...slugs]] 20.66 KB 264.35 KB 117.49% (🟢 -0.03%)
/[language]/teachings/[id]/[[...slug]] 20.66 KB 264.35 KB 117.49% (🟢 -0.03%)
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 5% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/- <0.01%" it means that there was a change in bundle size, but it is a trivial enough amount that it can be ignored.

@narthur narthur changed the title Fix prefetching and hydration AV-1153: Fix prefetching and hydration Aug 16, 2024
Copy link

github-actions bot commented Aug 16, 2024

Lighthouse Results

Copy link

github-actions bot commented Aug 16, 2024

Accessibility Issues

CodeNewFixedRetainedIgnoredTotal
WCAG2AA.Principle1.Guideline1_4.1_4_3.G18.Fail00025722572
View full summary

Copy link
Collaborator

@narthur narthur left a comment

Choose a reason for hiding this comment

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

Great work!

src/lib/hooks/useIsAuthenticated.ts Outdated Show resolved Hide resolved
@jakecoble
Copy link
Collaborator Author

jakecoble commented Aug 21, 2024

Steps used to identify missing prefetches:

  1. Open site in a new window
  2. Block https://graphql.audioverse.org/graphql
  3. Scroll through each page, comparing two versions of the site: one with the graphql endpoint blocked and one with the endpoint unblocked.
  4. Note any sections that are missing when the endpoint is blocked.
  5. Ensure those sections are fetched in prefetchQueries in that page's getServerSideProps and getStaticProps functions.

Steps used to find fetches that weren't using the generated queries:

  1. Grep codebase for @tanstack/react-query imports.
  2. Modify files using react-query directly to use the generated query code.

@narthur
Copy link
Collaborator

narthur commented Aug 30, 2024

Great work, @jakecoble!

@jakecoble jakecoble force-pushed the prefetching-and-hydration-fixes branch from e30dedf to e553d40 Compare September 19, 2024 19:07
Copy link
Collaborator

@narthur narthur left a comment

Choose a reason for hiding this comment

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

Great work!

Copy link
Contributor

@alangumer alangumer left a comment

Choose a reason for hiding this comment

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

Great work!

@narthur narthur merged commit b16dbb1 into master Sep 27, 2024
12 checks passed
@narthur narthur deleted the prefetching-and-hydration-fixes branch September 27, 2024 16:12
jakecoble added a commit that referenced this pull request Sep 27, 2024
Squashed commit of the following:

commit b16dbb1
Merge: 3e7de6a 50a949b
Author: Nathan Arthur <[email protected]>
Date:   Fri Sep 27 12:12:52 2024 -0400

    Merge pull request #570 from audioverse-org/prefetching-and-hydration-fixes

    AV-1153: Fix prefetching and hydration

commit 50a949b
Author: Jake Coble <[email protected]>
Date:   Fri Sep 27 11:51:16 2024 -0400

    Update vulnerable dependency

commit c597584
Author: Henry Orozco <[email protected]>
Date:   Fri Sep 27 09:47:00 2024 -0600

    refactor: use codegen hook for useGetLibraryPlaylistPageDataQuery

commit 921fa3c
Author: Jake Coble <[email protected]>
Date:   Fri Sep 27 10:55:12 2024 -0400

    Fix generated query keys in doPrefetch

commit fb00185
Author: Jake Coble <[email protected]>
Date:   Sun Sep 22 11:26:32 2024 -0400

    Whitelist CVE

commit e553d40
Author: Jake Coble <[email protected]>
Date:   Thu Sep 5 16:00:25 2024 -0400

    Add getIsAuthenticated to user session query keys

commit def7712
Author: Jake Coble <[email protected]>
Date:   Mon Sep 2 10:02:15 2024 -0400

    Replace useGetIsAuthenticatedQuery with useIsAuthenticated

commit f4b7fa7
Author: Jake Coble <[email protected]>
Date:   Thu Aug 22 14:57:14 2024 -0400

    Rename withAuthGuard query to getIsAuthenticated in hooks directory

commit 8e6bbff
Author: Jake Coble <[email protected]>
Date:   Sun Aug 18 14:46:53 2024 -0400

    Use generated infinite query function on sponsor page

commit 5fe0648
Author: Jake Coble <[email protected]>
Date:   Fri Aug 16 15:40:50 2024 -0400

    Prefetch audiobook slider data
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

Successfully merging this pull request may close these issues.

3 participants