Get the latest tech news
The Chrome Speculation Rules API allows the browser to preload and prerender
Discover how to significantly boost your website's loading speed by adding just 5 lines of HTML. Simple steps for faster websites.
<script>if (!HTMLScriptElement.supports||!HTMLScriptElement.supports('speculationrules')){constpreloadedUrls={};functionpointerenterHandler(){if (!preloadedUrls[this.href]){preloadedUrls[this.href]=true;constprefetcher=document.createElement('link');prefetcher.as=prefetcher.relList.supports('prefetch')?'document':'fetch';prefetcher.rel=prefetcher.relList.supports('prefetch')? 'prefetch':'preload';prefetcher.href=this.href;document.head.appendChild(prefetcher);}}document.querySelectorAll('a[href^="/"]').forEach(item=>{item.addEventListener('pointerenter',pointerenterHandler);});}</script>
Or read this on Hacker News