prefetch

Prefetch upcoming page assets using HTML link rel=prefetch, Webpack magic comments, or service workers.

235|25|Updated Mar 24, 2026
One-click install
npx skills add https://github.com/PatternsDev/skills --skill prefetch
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: prefetch
Source: https://github.com/PatternsDev/skills/tree/main/javascript/prefetch
Command: npx skills add https://github.com/PatternsDev/skills --skill prefetch

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Prefetching resources helps reduce perceived latency by loading assets you expect the user will need next before they are requested.

Core Features & Use Cases

  • Declarative prefetch via HTML link rel="prefetch" to fetch upcoming resources during idle time.
  • Build-time hints like Webpack magic comments to prefetch modules.
  • Service Worker strategies to prime caches for anticipated navigations.
  • Use Case: When routing users to a known next page, prefetch the JS/CSS for that page to speed up navigation.

Quick Start

Use HTML rel="prefetch" tags or bundler hints to start prefetching resources you expect users will navigate to soon.

Frequently Asked Questions about prefetch

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prefetch resources to speed up SPA navigation?

You can prefetch resources to speed up SPA navigation by using HTML link rel=prefetch, Webpack magic comments, or service worker strategies to load likely-needed assets in advance. This reduces perceived latency by fetching assets during idle time before they are requested.

What is the best way to reduce perceived latency for predictable user routing?

The best way to reduce perceived latency for predictable user routing is prefetching likely-needed assets in advance. By loading expected assets before the user requests them, you minimize wait times during known navigation flows.

How do I use Webpack magic comments to prefetch modules?

You can use Webpack magic comments to prefetch modules by adding /* webpackPrefetch: true */ to your dynamic imports. This build-time hint instructs the bundler to load anticipated modules during browser idle time.

Can I use a service worker to prefetch resources for anticipated navigations?

Yes, you can use a service worker to prefetch resources for anticipated navigations. Service worker strategies can prime caches in advance, ensuring assets are ready before the user navigates to the next page.

When should I not use link rel=prefetch for resource loading?

You should not use link rel=prefetch for resource loading when user navigation is unpredictable or resources are unlikely to be needed. Prefetching unnecessary assets wastes bandwidth and browser idle time without reducing perceived latency.

Does prefetching work with predictable navigation flows in single page applications?

Yes, prefetching works effectively with predictable navigation flows in single page applications. It applies to routing users to upcoming pages or components, minimizing wait times by loading expected assets in advance.