appendSpeculationRules() — astro Function Reference
Architecture documentation for the appendSpeculationRules() function in index.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 48f302df_372c_1a3e_b7a1_ac529c030249["appendSpeculationRules()"] 315e53ea_6d34_137c_ce5c_8c89aca90db9["index.ts"] 48f302df_372c_1a3e_b7a1_ac529c030249 -->|defined in| 315e53ea_6d34_137c_ce5c_8c89aca90db9 1502f987_7806_fcef_2f8e_55d799080686["prefetch()"] 1502f987_7806_fcef_2f8e_55d799080686 -->|calls| 48f302df_372c_1a3e_b7a1_ac529c030249 style 48f302df_372c_1a3e_b7a1_ac529c030249 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/prefetch/index.ts lines 332–355
function appendSpeculationRules(url: string, eagerness: PrefetchOptions['eagerness']) {
const script = document.createElement('script');
script.type = 'speculationrules';
script.textContent = JSON.stringify({
prerender: [
{
source: 'list',
urls: [url],
eagerness: eagerness,
},
],
// Currently, adding `prefetch` is required to fallback if `prerender` fails.
// Possibly will be automatic in the future, in which case it can be removed.
// https://github.com/WICG/nav-speculation/issues/162#issuecomment-1977818473
prefetch: [
{
source: 'list',
urls: [url],
eagerness: eagerness,
},
],
});
document.head.append(script);
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does appendSpeculationRules() do?
appendSpeculationRules() is a function in the astro codebase, defined in packages/astro/src/prefetch/index.ts.
Where is appendSpeculationRules() defined?
appendSpeculationRules() is defined in packages/astro/src/prefetch/index.ts at line 332.
What calls appendSpeculationRules()?
appendSpeculationRules() is called by 1 function(s): prefetch.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free