← /lab
Speculation Rules
Speculation Rules let a page tell the browser which link you'll probably open next, so it can load (and even render) that page before you click. This experiment checks whether that makes this site faster.
Try it
Each link opens the same page, which tells you how it was loaded. Rest the pointer on a link for a moment before clicking.
- Prerendered link: a plain link this page's rules prerender when you point at it.
- Plain link: a normal full page load, for comparison.
- Next.js link: how every other link on this site works.
What I found
- Chrome accepts the rules: pointing at the first link makes it start loading the target. The target page then tells you whether it was prerendered. Chrome turns prerendering off while DevTools is open, so try it with DevTools closed.
- The Next.js link is fast without any of this. Next.js fetches the data of every page a link shows as soon as the link is on screen, then swaps the page in without loading a new document. In my tests it was as quick as the plain link.
- Every link on this site is a Next.js link. Its click never uses a prerendered document, so a site-wide rule would download and render pages a second time for nothing: more data and battery, no gain.
- So the rules stay on this page only. They cover just the links marked
data-speculate, only start when you point at one, and are removed when you leave, so Chrome can drop a prerender nobody used. - They'd be worth it for plain links to static pages, for example links inside long written posts, if the site gets those.
Browser support and fallback
- Chrome and Edge run these rules. Safari and Firefox ignore them, and every link simply loads normally.
- Chrome also skips speculation when Data Saver or Energy Saver is on, or memory is low, and limits how many pages it prerenders at once.
- A prerendered page runs its code before you see it. The target waits until it is shown before it reports anything (
prerenderingchange).