Browse AjaxPress docs

Prefetch on hover

On this page

Prefetch makes page changes feel instant. When a visitor’s pointer rests on a link, AjaxPress starts loading that page in the background. By the time they click, the page is usually ready, and it appears straight away.

It needs AjaxPress Pro.

Turn it on

Go to Settings โ†’ AjaxPress โ†’ Basic, turn on Enable Prefetch, and Save Settings. It only shows while Enable SPA for Frontend is on.

With Enable Prefetch, a page starts loading when the visitor hovers a link.

How it behaves

  • A short pause first. Prefetching starts once the pointer has rested on a link for a tenth of a second. Moving across a menu doesn’t load every item on the way.
  • One page at a time. A new hover replaces the page loaded for the previous one, so the extra load on your server stays small.
  • Only links AjaxPress would handle. Links to other sites, new-tab links, downloads, # anchors, wp-admin, and excluded links are never prefetched.
  • Nothing changes until the click. A prefetched page stays hidden. If the visitor clicks somewhere else, it’s simply dropped.

Desktop only, in practice

Prefetch relies on hovering. On phones and tablets there’s no hover, so pages load on tap as usual.

Is it safe for my server?

For most sites, yes. Each prefetch is one ordinary page request, the same as a visit, and it only happens after a deliberate pause over a link. Your page cache serves it like any other request.

Think twice on a site where loading a page does something:

  • Links that act when visited. Some links do something the moment their page is loaded: a Log out link, a WooCommerce Add to cart link on a shop page, or a “delete” or “unsubscribe” link. A prefetch loads the page, so it can carry out the action before the visitor clicks. Add these to Exclude Links, and they’re never prefetched:
action=logout
customer-logout
add-to-cart=
  • Page view counts. A prefetched page loads in full, out of sight, with its scripts. So a page a visitor hovered but never opened can be counted as a page view: by server-side statistics, and by browser analytics such as Google Analytics too. If exact page view numbers matter more to you than speed, leave prefetch off, or compare your numbers for a week with it on and off. See Analytics, Tag Manager and consent banners.

Pair it with a transition

Prefetch and page transitions work well together: a short Fade on a page that’s already loaded feels smooth rather than slow.

For developers

To prefetch a page from your own code, such as the next episode once a podcast starts, use AjaxPress.preload(url). See the JavaScript extension API.