- Issue created by @cosmicdreams
During Google I/O 2024 there was a great presentation on the Speculation Rules API
https://youtu.be/bSua9vMdrNM
During the talk this sample code was shown: (composited from two code samples during the video)
<script type="speculationrules">
{
"prerender": [{
"where": {
"and": [
{ "href_matches: "/*" },
{ "not": {"href_matches": "/wp-admin"}},
{ "not": {"selector_matches": ".do-not-prerender"}},
{ "not": {"selector_matches": "[rel=nofollow]"}}
]
},
"eagerness": "moderate"
}]
}
With the Speculation Rules API working in your browser what this would do is prerender the first 10 links that have opt-ed out of prerendering (through the use of the class or nofollow) or is an administrative link (for the hypothetical Wordpress site), but only when the user hovers (or click down event) their mouse on the link.
The API also provides:
The impact of this change is to get as close to instant loading of pages as possible. As I mentioned above there appear to be some built-in limitations of the prerendering. These ultimatley make sense when you consider that you might arrive on a page with 100s of links. You don't want them all to prefetch + prerender. That would be a lot of traffic caused by a single page view.
All that said, I wonder if this module can adapt to the new API? What I think would be needed is:
If option 2 is possible, maybe someday we wouldn't actually need a module it could just be part of a theme that is extended.
Gauge interest in this idea
Plan Next Steps
Let's chat through the details here or in slack.
Active
2.0
Code