There's a simple trick to making a website feel faster than it is: start loading the next page before the visitor asks for it. Developers have done versions of this for years with prefetch hints and JavaScript libraries. The Speculation Rules API makes it built-in, more powerful, and much easier to control.
What it does
You add a small block of JSON to your page that tells the browser which links it may prefetch or prerender.
- Prefetch downloads the next page's HTML in advance, so the click skips the network wait.
- Prerender goes further. It loads and renders the whole page invisibly in the background. When the visitor clicks, the page appears instantly, because it's already done.
The rules can target specific URLs, or match links by pattern ("all links under /blog/"), and you can control how eagerly the browser acts: immediately, when the user hovers over a link, or when they start pressing it.
A typical setup
For a content site, our usual starting point is:
- Prefetch links that match
/, excluding things like/admin/,/logoutand cart actions. - Use "moderate" eagerness, which triggers when the visitor hovers over a link for a short moment on desktop.
- Prerender only a handful of the most likely next pages, like the main call-to-action.
On a client's services site, this made navigation between service pages feel instant on desktop. Their Largest Contentful Paint for those navigations dropped close to zero, because the page was already there.
Browser support
Speculation rules work in Chrome and Edge, which together are the majority of traffic for most Indian sites. Other browsers ignore the rules and navigate normally, so there's no downside for them. WordPress has also added support for speculative loading in core, so many WordPress sites already have a basic version switched on.
Things to be careful about
Don't prerender pages with side effects. If visiting a URL logs someone out, adds to cart, or changes data, it must be excluded. This is a good reminder that GET requests shouldn't change anything anyway.
Analytics. A prerendered page that the visitor never sees shouldn't count as a page view. Modern analytics tools handle this, but check yours. The page can detect prerendering and delay tracking until it's actually shown.
Server load. Prefetching means more requests. On a small hosting plan with a heavy site, being too eager can increase load noticeably. Start with moderate eagerness and watch your server.
Mobile data. Browsers are already conservative on mobile and on data-saver mode, but avoid aggressive prerendering of heavy pages.
Why we like it
Many performance improvements require serious work: rewriting code, changing hosting, redesigning pages. This one is a few lines added to your template, with a big visible impact. Combined with good caching and lean pages, it's one of the best value improvements you can make to a multi-page website right now.
