Skip to content

feat(pages): prefetch a visible Link only after it stays in view - #701

Merged
cpojer merged 2 commits into
voidzero-dev:mainfrom
yangshun:claude/link-visible-prefetch-delay-1cde58
Nov 4, 2026
Merged

cpojer merged 2 commits into
voidzero-dev:mainfrom
yangshun:claude/link-visible-prefetch-delay-1cde58

Conversation

@yangshun

@yangshun yangshun commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

A 'visible' Link now prefetches only after it has been in view for 300 ms. Scrolling it out of view cancels the wait, and coming back restarts it.

300 ms skips links scrolled past quickly in long lists, now that 'visible' can be the app-wide default.

Precedent: Astro debounces viewport prefetches by the same 300 ms, and TanStack Router applies preloadDelay to viewport preloads, cancelling when the link leaves the viewport.

Tests: fake-timer unit cases for the delay, cancel, restart, firing once, and cleanup.

🤖 Generated with Claude Code

A Link with the 'visible' strategy now waits until it has been in the
viewport for 300 ms before prefetching. Leaving the viewport cancels the
wait, entering again restarts it, and unmounting clears it, so links
scrolled past in a long list are not prefetched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yangshun
yangshun marked this pull request as draft November 4, 2026 06:40
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yangshun
yangshun marked this pull request as ready for review November 4, 2026 06:44

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Makes sense. We should get this out and then see if we should adjust the thresholds a bit.

@cpojer
cpojer merged commit 03661c0 into voidzero-dev:main Nov 4, 2026
18 checks passed
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.

2 participants