Skip to main content
Web DevPerformance & OptimizationDiagramBeginner

Prefetching

KO: 프리페칭 (Prefetching)·EN: Prefetching·JA: プリフェッチ(Prefetching)

A proactive optimization that fetches likely next-page code or data during browser idle time so subsequent navigations feel instantaneous

Table of Contents

Structure Diagram

Standard Click Load vs Idle Prefetch Instant Navigation
Standard Navigation3 steps
With Prefetching2 steps
STEP 1Reading Page (Idle)(48ms)
Quick Answer

What is Prefetching?

A proactive optimization that fetches likely next-page code or data during browser idle time so subsequent navigations feel instantaneous. It is a core concept in Performance & Optimization within Web Dev.

Core Principles

Prefetching uses idle network time—triggered by link visibility, hover intent, or focus—to fetch likely next-page chunks, HTML, or API data at low priority into cache before the user clicks.

Implemented via <link rel="prefetch">, the browser Speculation Rules API, or framework routers like Next.js <Link> and TanStack Query prefetchQuery, it eliminates perceived navigation latency without competing with current-page critical resources.

Practical Takeaways

  • Balance eagerness against bandwidth: Prefetching every link on a 100-item catalog wastes mobile data and spikes server load. Prefetch primary CTAs on viewport entry and list items on hover/pointer-down intent.
  • Respect data-saver preferences: Disable speculative prefetching when navigator.connection?.saveData is true or on slow cellular connections.
  • Don't confuse preload with prefetch: Use preload for high-priority assets needed on the current page (LCP image, primary font) and prefetch for low-priority assets for the next navigation.

Notable Examples

  • Next.js <Link>: Automatically prefetches linked route bundles and RSC payloads as links enter the viewport.
  • TanStack Query prefetchQuery: Warms detail-page API caches on row hover so opening an item skips loading spinners entirely.