Skip to content

Instantly share code, notes, and snippets.

@nucliweb
Created May 19, 2024 18:25
Show Gist options
  • Save nucliweb/1b103bb838c154664d4914508925ea45 to your computer and use it in GitHub Desktop.
Save nucliweb/1b103bb838c154664d4914508925ea45 to your computer and use it in GitHub Desktop.
Speculation Rules Script
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