Speculative Loading settings page showing Speculation Mode (Prefetch/Prerender) and Eagerness level configuration

This module is included in DXPR CMS.

Speculative Loading enables browsers to preload pages users are likely to visit next, creating near-instant navigation experiences on your Drupal site. By intelligently prefetching or prerendering pages based on user interactions, this module dramatically improves perceived performance without requiring complex technical setup.

You need Speculative Loading if

  • You want to improve your site's perceived performance and navigation speed
  • You need near-instant page loading without complex technical setup
  • You want to implement modern browser performance features easily
  • You're focused on user experience and reducing page load times
  • You want performance improvements that work automatically with no ongoing maintenance

Speculative Loading settings page showing Speculation Mode (Prefetch/Prerender) and Eagerness level (Conservative, Moderate, Eager) configuration

Features

  • Implements the modern Speculation Rules API to improve website performance
  • Supports both prefetch (lightweight) and prerender (full-page) modes
  • Configurable eagerness levels (Conservative, Moderate, or Eager) to balance performance and resource usage
  • No code required: works automatically on standard Drupal frontend pages
  • "No-prerender" CSS class can be added to exclude specific links
  • Hook API allows programmatic exclusion of URL patterns
  • Plugin system for extending functionality with custom rules

Post-Installation

After installing the module, it works immediately with default settings. To customise:

  1. Navigate to "Configuration" > "Development" > "Performance" > "Speculative Loading"
  2. Choose between "Prefetch" or "Prerender" mode (prerendering provides faster experiences but may affect interactive content)
  3. Select your preferred eagerness level
  4. Save your configuration

No additional setup is required as the module automatically adds the necessary markup to your pages.

Speculative Loading detailed settings showing speculation mode toggle between Prefetch and Prerender with eagerness level options

While not required, these core modules complement Speculative Loading:

  • BigPipe - Progressive page rendering for the initial load; Speculative Loading handles subsequent navigations
  • Internal Page Cache - Caches full pages for anonymous users, making prerendered pages even faster to serve

Supporting this Module

This module is maintained by DXPR. If you find it valuable, consider checking out our free page builder (with paid features for large websites):
- https://www.drupal.org/project/dxpr_builder

Community Documentation

- Speculation Rules API on MDN
- Chrome's documentation on prerendering

The module generates speculation rules as a JSON snippet injected into each page, instructing the browser which links to prefetch or prerender:

Generated speculation rules JSON output showing the prefetch configuration with eagerness and URL matching rules added to the page source

Browser Support

The Speculation Rules API is supported in modern Chromium-based browsers (Chrome, Edge, Opera). Other browsers will gracefully ignore the functionality with no negative effects.

Wider browser support is underway: Firefox is actively working on implementing the Speculation Rules API. You can track their progress here: Firefox Bug #1969396

FAQ

Which browsers support the Speculation Rules API?

Chromium-based browsers (Chrome, Edge, Opera) fully support the Speculation Rules API. Firefox is actively implementing support (tracked in Bug #1969396). Browsers that do not support the API simply ignore the speculation rules with no negative effects on functionality or performance. The module is safe to enable on any site.

What is the difference between prefetch and prerender mode?

Prefetch downloads the page's resources (HTML, CSS, JavaScript) in advance but does not execute them. Prerender goes further and fully loads and renders the page in a hidden tab, making navigation appear instant. Prerender provides faster experiences but uses more bandwidth and may affect pages with interactive content or analytics tracking.

Does Speculative Loading increase server load?

The processing happens entirely in the visitor's browser; the module only adds a small JSON snippet to each page telling the browser what to preload. Server load depends on how aggressively browsers prefetch pages and how many visitors your site has. The eagerness setting (Conservative, Moderate, or Eager) controls how many pages browsers preload.

Related Modules

Modules that complement Speculative Loading for Drupal performance:

  • BigPipe - Drupal core module for progressive page rendering; works alongside Speculative Loading to reduce both initial and subsequent page load times
  • Internal Page Cache - Drupal core caching for anonymous users; caches the pages that Speculative Loading prerenders
  • DXPR Theme - Responsive Drupal theme with built-in performance optimizations
  • DXPR Builder - Drag-and-drop page builder for Drupal

Speculative Loading is included in DXPR CMS, a Drupal distribution focused on performance and marketing team productivity.

Supporting organizations: 
Sponsor

Project information

Releases