tunetheweb


Add support for Speculation Rules

Is your feature request related to a problem? Please describe.

Chrome has recently launched the Speculation Rules API which provides a way of a page telling the browser to prefetch or prerender a future navigation with a simple JSON-based objected added to the page (or referred to from an HTTP Header), which either lists the list of URLs, or gives details of hrefs patterns or CSS selector matches to find links on the page. I recently presented on this at Google I/O 2024, which provides a good summary for those willing to sit through my jammering on about it for 30mins.

Speculation Rules is for full page, browser-controlled, navigations (some people use the "MPA" term, but I like to call them "webpages" 🙂), which means they are ideally suited for SSG sites using things like 11ty!

While SSG sites often are fast by default, faster perf is always a good thing IMHO, as long as the balance between effort versus reward makes it worthwhile—which we believe it is for this API.

Describe the solution you'd like

I'm wondering what opportunities there are to more fully integrate this into 11ty?

I realise this is a fairly open ended question, but keen to hear the community's thoughts on this. I'm more than willing to answer any questions, and even help with any implementation here.

Describe alternatives you've considered

I did consider a plugin for this, and had a look and discovered that a plugin already exists. Maybe that's sufficient and we don't need to do anything further here? Or maybe implementing this in the main 11ty codebase/repo would be better if we think this would have high value for 11ty users?

Additional context

As a similar use case, we created a WordPress plugin for that platform and it has been received very positively. We're also considering proposing adding this to WordPress core if the plugin proves successful. We're willing (and in fact keen!) to work with other platforms where this API would potentially add a lot of value.