Last active
May 27, 2024 08:11
-
-
Save aaronpeters/1701090f36caf3f71009ff7e9576a5d0 to your computer and use it in GitHub Desktop.
Speculation Rules Suitable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( | |
HTMLScriptElement.supports && | |
HTMLScriptElement.supports("speculationrules") | |
) { | |
const specScript = document.createElement("script"); | |
specScript.type = "speculationrules"; | |
specRules = { | |
prefetch: [ | |
{ | |
where: { | |
and: [ | |
{ | |
href_matches: "/*", | |
}, | |
{ | |
not: { | |
href_matches: "/logout", | |
} | |
} | |
] | |
}, | |
eagerness: "moderate" | |
} | |
] | |
}; | |
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