Vai al contenuto

Pages already built: Speculation Rules and the time customers do not wait

Since 25.9 Maho prepares the next page before the click, with CSS rules and three eagerness levels: faster navigation, better Core Web Vitals.

The time a customer feels on a store is not the loading time of the home page: it is the time between the click on a product and the moment the price appears. The browser, though, cannot predict that click, and it only starts working once the finger is already on the link. Speculation Rules exist for exactly this: tell the browser which links are worth preparing in advance, so the next page is ready when it is needed. Since 25.9 the Maho core supports them, with rules written in CSS and three eagerness levels.

What the browser does, in two ways

The standard defines two levels of preparation, and keeping them apart matters because they cost different things.

  • Prefetch: the browser downloads the page resources in advance without building the page. Cheap, and it makes navigation faster.
  • Prerender: the browser builds the page in the background, so at click time it is ready. Faster, and much more expensive in memory and CPU.

On top of that comes eagerness, meaning when the browser starts: immediately on page load (eager), after 200 milliseconds of hovering the link (moderate), or on mouse or touch down, just before the click (conservative).

🔮 A note in advance: conservative does not mean timid. The conservative level is the one nobody notices and nobody regrets, because it only prepares the page the customer is about to open.

Where it lives

System > Configuration > Advanced > Developer > Speculation Rules API. There is one switch and six text areas, one for each combination of mode and level: prefetch and prerender, each for eager, moderate and conservative. Every box takes one CSS selector per line, and the browser applies the rule to matching links.

The module ships with a prudent configuration already written into the defaults, pointing at moderate prefetch for navigation links:

a.logo
.nav-primary a
.breadcrumbs a
.product-name a
.product-image a
.toolbar .pager a
.footer a

Those are the links a customer uses to move between catalog, categories and product pages. Start there, and widen only what you have measured.

Why it improves both experience and scores

The gain shows on two levels, and it pays to be precise because confusion around this is widespread.

User experience: the customer clicks a product page and it is already there. The pause where the screen sits still and people click again is gone, and the double click rate falls. On a phone on a mobile network the difference is louder than on a fibre desktop.

PageSpeed scores: the Core Web Vitals that matter for search are the field ones, the real data browsers report in PageSpeed Insights and Search Console. Preparing the next page improves exactly those navigation measurements, because the wait between one page and the next gets shorter. The lab score of a single page, the one you get by running a test on a URL, does not change: that test measures a cold load and has no click to anticipate.

Put usefully: Speculation Rules do not make a slow page look fast, they make the next page feel instant. On a store, where people navigate by definition, that is half the problem.

🔮 A note in advance: a high lab score with slow navigation is the portrait of a store that optimised the home page and nothing else.

How not to overdo it

The classic mistake is putting a in the eager prerender box. The browser starts building every visible link the moment the page opens, the CPU spends itself on pages nobody will open, and the current page slows down exactly while the customer is looking at it.

Three rules that avoid the problem:

  1. Prerender only on conservative, so at click time, and only for a short list of links.
  2. Moderate prefetch for normal navigation: catalog, categories, product pages.
  3. No pages with side effects, such as cart or checkout, because a page built in the background must not run anything that changes state.

One last thing worth knowing: store analytics also see the pages prepared and never opened. If the traffic report seems to grow without orders growing, this can be the cause, and it is not a bug.

🔮 A note in advance: a page prepared and never opened is still time well spent. The browser bet on a click and lost, but the bet was cheap.

How to measure it

Before touching the selectors, read the field data: PageSpeed Insights for a couple of key URLs and the Core Web Vitals report in Search Console, which reasons by groups of pages. Then switch moderate prefetch on, wait a few weeks and compare. If navigation time drops, widen. If the CPU of the current page rises, tighten.

One boundary note: Speculation Rules work on the browsers that support them, and where they are not supported they simply do nothing. There is no fallback to write and no case where they make things worse, as long as you do not overdo the eager level.

Text prepared with the help of AI and checked against the source before publication. It can still contain mistakes: if you find one, report it.Read the manifesto

Does your store still sell?

Tell us where you are starting from: we reply with a first assessment, no strings attached.

Ask for the store assessment