Skip to content

Instantly share code, notes, and snippets.

@thangman22
Created March 9, 2025 11:13
Show Gist options
  • Save thangman22/56537f3ac74d509fb18b6d0ae2a4add8 to your computer and use it in GitHub Desktop.
Save thangman22/56537f3ac74d509fb18b6d0ae2a4add8 to your computer and use it in GitHub Desktop.
if (HTMLScriptElement.supports?.('speculationrules')) {
const specScript = document.createElement('script');
specScript.type = 'speculationrules';
const specRules = {
prerender: [
{
urls: ['/next.html'],
},
],
};
specScript.textContent = JSON.stringify(specRules);
document.body.append(specScript);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment