Skip to content

Conversation

@yujiteshima
Copy link
Contributor

Summary

Makes PREFETCH_DELAY configurable via Turbo.config.drive.prefetchDelay, addressing #1481.

The current hardcoded 100ms delay can cause excessive prefetch requests on pages with many links (e.g., image galleries where cursor movement frequently hovers over multiple links).

Changes

  • Added prefetchDelay to Turbo.config.drive (default: 100ms)
  • Modified PrefetchCache to read the delay dynamically via a getter, so changes take effect immediately
  • Added unit test for the new configuration option

Usage

// Increase delay for pages with dense link areas
Turbo.config.drive.prefetchDelay = 300

This follows the existing pattern used by Turbo.config.drive.progressBarDelay.

Allow developers to customize the prefetch delay (default: 100ms) to
optimize for different use cases. For example, image galleries with
many linked items may benefit from a longer delay to avoid triggering
excessive prefetch requests during rapid cursor movement.

Usage:
  Turbo.config.drive.prefetchDelay = 300 // Set to 300ms

Fixes hotwired#1481
@kinoute
Copy link

kinoute commented Jan 10, 2026

@yujiteshima Awesome, thank you! Hopefully it gets merged soon

@davidalejandroaguilar
Copy link
Contributor

Hope this gets reconsidered, my PR was closed last year #1164

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants