Faster next-page loads by prefetching and prerendering links using the browser's native Speculation Rules API. It improves perceived performance, UX, and Core Web Vitals.
⚠️ Speculation Rules are supported only on Chromium-based browsers (v121+). Other browsers simply ignore the rules — no errors, no fallback needed.
- Immediate prefetch — automatically prefetch the first N items on post/product/category listing pages (default 4, configurable).
- Immediate prerender — fully prerender the first N listing items, like an invisible background tab (default 3, configurable).
- Hover (moderate) prefetch/prerender — speculate a destination when the user hovers a link, just before the click.
- Per-post custom URLs — specify exact URLs to prefetch/prerender from a given post, product, or page via a metabox.
- Exclusions — skip URLs by path, with RegEx-style
href_matchespatterns for hover mode, plus aselector_matchesCSS opt-out (.no-prefetch/.no-prerender/rel="nofollow"). - Safe by default — state-changing GET links (login, admin, comments, checkout/my-account,
add-to-cart, nonce-bearing URLs) are excluded out of the box. - WordPress 6.8 core-aware — integrates with core Speculative Loading and suppresses core's block when active to avoid duplicate rules.
- No-Vary-Search — one entry can match URLs differing only by tracking/sort query params.
- Configurable eagerness —
conservative/moderate/eagerper feature.
| What it does | Cost | Best for | |
|---|---|---|---|
| Prefetch | Downloads the next page's document only | Low | Broad coverage of likely-next links |
| Prerender | Fully renders the next page in the background | Higher | A small number of very-likely next pages |
- WordPress 5.3+
- PHP 7.4+
- A Chromium-based browser (v121+) on the visitor side to benefit from speculation
- Download or clone this repository into your
wp-content/plugins/directory:git clone https://github.com/Oxyplug/oxy-prefetch.git wp-content/plugins/oxyplug-prefetch
- Activate Oxyplug Prefetch & Prerender from the WordPress Plugins screen.
- Configure under Tools → Oxyplug Prefetch & Prerender.
The Material Design 3 admin components are bundled in assets/js/dist/. To rebuild them:
npm install
npm run build- Go to Tools → Oxyplug Prefetch & Prerender.
- Enable and tune:
- Prefetch — number of immediate prefetches, and/or hover prefetch.
- Prerender — number of immediate prerenders, and/or hover prerender.
- Exclusion — paths to skip (RegEx allowed for hover mode).
- On any post/page/product edit screen, use the Oxyplug Prefetch & Prerender metabox to add custom URLs to prefetch/prerender when that page is viewed.
| Pattern | Effect |
|---|---|
/logout |
Excludes the logout path |
/(page1|page2)/ |
Excludes URLs starting with page1 or page2 |
/custom_pages/* |
Excludes anything under custom_pages |
On the front end the plugin emits one or more <script type="speculationrules"> blocks in the footer:
- Immediate rules use a
listsource built from the current query's first N permalinks (and any per-post custom URLs). - Moderate rules use a
documentsource with a configurableeagerness, matching/*and excluding the configured paths and state-changing links vianot → href_matches/not → selector_matches, with optionalexpects_no_vary_search.
On WordPress 6.8+, the plugin detects core's own Speculative Loading: it feeds its default exclusions into core and, when any of its features are enabled, suppresses core's block so the page never ships two competing rule sets.
- Main plugin logic:
oxy-prefetch.php - Admin script:
assets/js/admin-script.js - Block-editor integration:
assets/js/gutenberg-script.js - MD3 components:
assets/js/src/→ built toassets/js/dist/with Vite
Lint locally:
php -l oxy-prefetch.php
node --check assets/js/admin-script.jsSee readme.txt for the full changelog. Latest:
- Integrate with WordPress core Speculative Loading (WP 6.8+): feed default exclusions into core and suppress core output when the plugin's features are active, to avoid duplicate/competing rule sets
- Add No-Vary-Search support so prefetch/prerender entries still match URLs that differ only by tracking/sort query params (configurable param list)
- Make eagerness (
conservative/moderate/eager) configurable per feature for prefetch and prerender - Broaden default exclusions to protect state-changing GET links (
wp-login.php,wp-admin, comments, checkout/my-account,add-to-cart,remove_item,undo_item,_wpnonce,_wp_http_referer) - Add CSS opt-out via
selector_matches(.no-prefetch/.no-prerender/.no-speculationandrel="nofollow") - Add a prerender + analytics caveat note in the settings UI
- Add
oxy_prefetch_immediate_rules/oxy_prefetch_moderate_rulesfilters (e.g. to deliver rules via theSpeculation-RulesHTTP header) and exclusion filters - Tested up to WordPress 6.8
- Add
str_starts_with()polyfill for PHP 7.4 compatibility - Fix same-host validation for custom prefetch/prerender URLs
- Add capability checks to settings and notice AJAX handlers
- Use
wp_update_post()instead of direct DB writes - Add uninstall cleanup of options, transients, and post meta
- Load admin assets only on relevant screens
- Tested up to WordPress 7.0
GPLv2 or later — © Oxyplug