Browsers are clever, but they can only fetch what they know about. When a page loads, the browser discovers resources gradually: it reads the HTML, finds a stylesheet, downloads it, discovers a font referenced inside it, then downloads the font. Each step adds delay, especially when resources come from other domains that need new connections.
Resource hints let you tell the browser about important resources earlier. And speculative loading goes further, fetching or even rendering the next page a visitor is likely to visit before they click, so it appears almost instantly.
Used well, these techniques can make WordPress sites feel noticeably faster. Used carelessly, they waste bandwidth and can even slow pages down. Here’s how they work and how I use them.
The main resource hints
dns-prefetch
Tells the browser to look up a domain’s DNS in advance:
It’s lightweight and safe, saving a small amount of time on the first request to that domain.
preconnect
Goes further than dns-prefetch: the browser performs the DNS lookup, establishes the connection and completes the TLS handshake in advance:
Use preconnect for third-party domains you’ll definitely need early in the page load, like a CDN serving your hero image or a font provider. The crossorigin attribute is required when the resources will be fetched in CORS mode, such as fonts.
Don’t preconnect to too many domains. Each connection uses resources, and preconnecting to domains you won’t use soon is wasted effort. A handful of the most important domains is usually enough.
preload
Tells the browser to fetch a specific resource immediately, with high priority, because it will definitely be needed for the current page:
Preload is powerful for resources the browser discovers late, like:
- Fonts referenced inside CSS files.
- Hero images set as CSS backgrounds.
- Critical scripts loaded by other scripts.
The as attribute is required and must match the resource type. For fonts, crossorigin is required even for fonts on your own domain, otherwise the browser downloads the font twice.
prefetch
Tells the browser to fetch a resource at low priority because it might be needed for a future navigation:
Prefetch uses idle time and doesn’t compete with current page resources. It’s useful for likely next pages or resources needed on the next step of a flow.
Adding resource hints in WordPress
The wp_resource_hints filter
WordPress outputs some resource hints automatically, like dns-prefetch for certain domains used by enqueued resources. You can add or modify hints with the wp_resource_hints filter:
Preloading through wp_head
For preload hints, output them early in the head with wp_head at an early priority:
Many performance plugins also provide settings for preconnect, preload and prefetch, which is convenient if you don’t want to write code.
Preloading the LCP image
The Largest Contentful Paint element is often a hero image. If it’s a normal img element near the top of the HTML, the browser usually discovers it quickly, and since WordPress 6.3, WordPress adds fetchpriority=”high” to the image it expects to be the LCP element. Often, that’s enough.
Preload helps when the browser discovers the LCP image late:
- The image is a CSS background.
- The image is inserted by JavaScript, like a slider.
- The image is behind other render-blocking resources.
For responsive images, preload supports imagesrcset and imagesizes attributes, so the browser preloads the right size:
Only preload the LCP image on pages where it’s actually the LCP element. Preloading a hero image sitewide when most pages don’t have one wastes bandwidth on every page.
Speculative loading
Speculative loading means fetching or even rendering the next page before the user navigates to it. The modern approach uses the Speculation Rules API, a browser feature that lets a page describe which links can be prefetched or prerendered, and how eagerly.
- Prefetch downloads the next page’s HTML in advance.
- Prerender goes further, loading and rendering the next page in the background, so it appears instantly when clicked.
Speculative loading in WordPress
WordPress 6.8 introduced speculative loading in core. By default, it uses prefetch with a conservative eagerness setting, which means the browser prefetches a page when the user starts to click or tap a link. This gives a small speed boost on navigation with minimal wasted resources.
It’s designed to be safe by default, excluding URLs like the admin, login and links with query parameters that might trigger actions. Developers can adjust the behaviour with filters, such as changing to prerender or more eager settings, or excluding certain URL patterns.
Before WordPress 6.8, a feature plugin from the WordPress performance team provided this functionality, and it remains an option for adjusting settings.
Benefits and costs
Prerendering can make navigation feel instant, which is impressive on content sites and stores. But it has costs:
- Wasted bandwidth and server load when visitors don’t actually click the prefetched links.
- Analytics and side effects: prerendered pages may run scripts before the user sees them. Most modern analytics tools account for prerendering, but check.
- Dynamic or personalised pages may need exclusion.
Conservative or moderate eagerness settings balance benefit and cost for most sites. Aggressive settings make sense only where server capacity and caching can handle the extra requests.
Exclude what shouldn’t be speculated
Never prefetch or prerender URLs that change state, like logout links, add-to-cart links with parameters or links that trigger actions. WordPress’s default rules exclude common cases, but if your site has custom action URLs, make sure they’re excluded.
Common mistakes
- Preloading too much. Preload competes with other resources. Preloading ten fonts and five images slows down the things that matter most.
- Preloading resources that aren’t used. Browsers warn in the console when preloaded resources aren’t used within a few seconds. Watch for these warnings.
- Missing crossorigin on fonts, causing duplicate downloads.
- Preconnecting to many domains. Prioritise a few critical ones.
- Sitewide hints for page-specific resources, like preloading a homepage hero image on every page.
- Speculating dynamic URLs that change state or show personalised content.
Measuring the impact
Test changes with lab tools and real devices:
- Use the waterfall in WebPageTest or browser developer tools to see when resources start downloading before and after adding hints.
- Check whether LCP improves.
- Watch the console for unused preload warnings.
- Monitor Core Web Vitals field data over the following weeks.
If a hint doesn’t measurably help, remove it. Hints should earn their place.
A practical starting set
For a typical business site, my starting set of hints is small:
- Preconnect to the CDN or image domain, if images or assets come from another domain.
- Preload the main body font, if fonts are self-hosted and referenced from CSS.
- Preload the hero image only on pages where it’s a CSS background or otherwise discovered late.
- Let WordPress’s built-in speculative loading handle navigation, with default settings.
Then I measure. If a hint doesn’t improve the waterfall or LCP, it comes out. More hints rarely mean more speed; the right few hints do.
Hints and caching
Resource hints work best alongside good caching. Prefetched pages that are cached at the server or CDN load almost instantly and cost little server effort. Prefetched pages that aren’t cached force your server to generate pages that visitors may never view. If you increase speculative loading eagerness, make sure page caching is in place first.
Revisit hints after redesigns
Resource hints are tied to your current design. When you change the hero image approach, switch fonts or move assets to a new CDN, review your hints. Outdated preloads for files that no longer exist waste bandwidth and trigger console warnings on every page.
Test on slow connections
Resource hints matter most for visitors on slower mobile networks. Use your browser’s network throttling to test pages under realistic conditions and see whether hints actually change when key resources arrive.
Frequently asked questions
What’s the difference between preload and prefetch?
Preload fetches a resource needed for the current page, with high priority. Prefetch fetches something that might be needed for a future navigation, with low priority.
Should I preconnect to Google Fonts?
If you load fonts from an external provider, preconnecting to the font file domain helps. Self-hosting fonts removes the need entirely and is usually faster.
Does WordPress add resource hints automatically?
Yes, some. WordPress adds certain dns-prefetch hints, fetchpriority on likely LCP images and, since 6.8, speculative loading with conservative prefetching.
Is prerendering safe for WooCommerce stores?
Product and category pages can benefit, but exclude cart, checkout, account pages and action URLs. Test carefully and use conservative settings.
Final thoughts
Resource hints and speculative loading help the browser start work earlier. Preconnect to a few critical third-party domains, preload genuinely late-discovered resources like key fonts and background hero images, prefetch likely next pages and let WordPress’s built-in speculative loading speed up navigation with sensible defaults. Measure the effect of every hint, avoid preloading too much and never speculate URLs that change state. Small, well-chosen hints can make a site feel noticeably faster.




