Dries Buytaert Revisits Prefetching with Speculation Rules API

Dries Buytaert Revisits Prefetching with Speculation Rules API

Rethinking the role of prefetching in modern web performance is the focus of a new blog post by Dries Buytaert, who argues that the Speculation Rules API has changed his long-standing concerns about the technology's impact on bandwidth, battery life, and resource consumption.

Dries writes that he has traditionally viewed prefetching with caution because it can require browsers to spend bandwidth, CPU resources, memory, and battery power loading pages that users may never visit. He also argues that prefetching should never be used to compensate for poorly optimised websites weighed down by excessive JavaScript, third-party scripts, large assets, or unnecessary complexity.

His perspective shifted while updating an HTTP header analysis tool to support the Speculation-Rules HTTP header. The work led him to experiment with the Speculation Rules API on his own website and evaluate how modern browser-based prefetching differs from earlier approaches.

The Speculation Rules API allows websites to provide browsers with structured instructions about which links are safe to prefetch and under what conditions. These rules can be delivered directly within a page or through a dedicated HTTP header. For his blog, Buytaert configured rules that allow browsers to prefetch same-origin pages while excluding search-related URLs.

A key factor in his assessment is the use of the API's eagerness: conservative setting. Rather than prefetching links based on visibility or hover states, the browser waits until a user begins a click or touch interaction before initiating the request. According to Dries, this approach, prefetching, transforms from a speculative guess into a response to a strong signal of user intent.

The post contrasts this behaviour with traditional implementations using the <link rel="prefetch"> tag. While older methods can be effective in highly predictable workflows such as checkout processes or setup wizards, Dries notes that predicting a visitor's next action on a content-driven website is far less reliable and can result in unnecessary resource consumption.

He also highlights safeguards built into modern browser implementations. Speculation Rules can respect Battery Saver and Data Saver settings, allowing browsers to skip prefetching when devices are conserving resources or operating under constraints.

Another advantage, he argues, is the ability to define which paths are safe for prefetching. Browsers generally avoid making assumptions about arbitrary links because some actions, such as visiting a logout page, could have unintended consequences if loaded automatically. Speculation Rules provide developers with a mechanism to explicitly identify safe destinations while excluding sensitive routes.

Despite embracing the new approach, Dries reiterates that performance optimisation should remain the primary objective. He argues that websites should first focus on reducing unnecessary complexity and improving baseline performance before introducing prefetching technologies.

The article concludes that Speculation Rules make prefetching more responsible by limiting speculative requests, waiting for clear user intent, and allowing browsers to make informed decisions about when and how resources should be loaded.

Disclosure: This content is produced with the assistance of AI.

Disclaimer: The opinions expressed in this story do not necessarily represent that of TheDropTimes. We regularly share third-party blog posts that feature Drupal in good faith. TDT recommends Reader's discretion while consuming such content, as the veracity/authenticity of the story depends on the blogger and their motives. 

Note: The vision of this web portal is to help promote news and stories around the Drupal community and promote and celebrate the people and organizations in the community. We strive to create and distribute our content based on these content policy. If you see any omission/variation on this please reach out to us at #thedroptimes channel on Drupal Slack and we will try to address the issue as best we can.

Related People

Upcoming Events

Latest Opportunities