perf: prefetch sidebar links on hover, not in viewport - #1976
Draft
marcleblanc2 wants to merge 1 commit into
Draft
marcleblanc2 wants to merge 1 commit into
marcleblanc2 wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Next prefetches every <Link> that scrolls into view. The sidebar shows dozens at once, so one page load fetched ~80 RSC payloads (377 KB on the wire, 2.4 MB decoded). NavigationLink keeps prefetch off until the user hovers or focuses the link, the pattern Next documents for large lists.
marcleblanc2
force-pushed
the
marc/perf/sidebar-prefetch
branch
from
September 17, 2026 02:32
e46d73d to
32ea28e
Compare
Contributor
Author
|
From the docs site audit (crawl of all 502 pages). Crawl numbers for the problem this PR fixes: ~35 RSC requests ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Next prefetches every
<Link>that enters the viewport. The sidebar shows dozens at once, so a single page view of/docs/batch-changes/delete-a-batch-changefetched 84 RSC payloads: 377 KB on the wire, 2.4 MB decoded, most of which the reader never clicks.Fix
New
NavigationLinkwrapsnext/linkwithprefetch={hasIntent ? null : false}, flipping to the default prefetch ononMouseEnter/onFocus. This is the hover-triggered prefetch pattern from the Next docs.Navigation.tsxswapsLinkfor it at its three link sites; nothing else changes.Tradeoffs
prefetch={false}everywhere was the simpler option but also kills hover prefetch; this keeps it.origin/enrique/sidebar-navigationtouchesNavigation.tsx; expect a small merge conflict at the import and the three<Link>tags.Verification
tsc,pnpm lint,pnpm buildclean. On the preview, open DevTools → Network, filter?_rsc=: the page load should fetch a handful, not ~80; hovering a sidebar link should fetch its payload.