init() — astro Function Reference
Architecture documentation for the init() function in index.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 6ed5ea2f_503c_fb78_a8ee_5c3ea9f2de4f["init()"] 315e53ea_6d34_137c_ce5c_8c89aca90db9["index.ts"] 6ed5ea2f_503c_fb78_a8ee_5c3ea9f2de4f -->|defined in| 315e53ea_6d34_137c_ce5c_8c89aca90db9 24714cbf_c269_c51b_a951_fe6138916c1c["initTapStrategy()"] 6ed5ea2f_503c_fb78_a8ee_5c3ea9f2de4f -->|calls| 24714cbf_c269_c51b_a951_fe6138916c1c 90b6d96b_d7f2_cf1e_695c_fcf15d5c6440["initHoverStrategy()"] 6ed5ea2f_503c_fb78_a8ee_5c3ea9f2de4f -->|calls| 90b6d96b_d7f2_cf1e_695c_fcf15d5c6440 8c99d8e4_b1d5_84e4_ba47_c797c9e87ba9["initViewportStrategy()"] 6ed5ea2f_503c_fb78_a8ee_5c3ea9f2de4f -->|calls| 8c99d8e4_b1d5_84e4_ba47_c797c9e87ba9 f350ee51_b3bd_e845_7222_24e2d4d0756a["initLoadStrategy()"] 6ed5ea2f_503c_fb78_a8ee_5c3ea9f2de4f -->|calls| f350ee51_b3bd_e845_7222_24e2d4d0756a style 6ed5ea2f_503c_fb78_a8ee_5c3ea9f2de4f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/prefetch/index.ts lines 34–52
export function init(defaultOpts?: InitOptions) {
if (!inBrowser) return;
// Init only once
if (inited) return;
inited = true;
debug?.(`[astro] Initializing prefetch script`);
// Fallback default values if not set by user config
prefetchAll ??= defaultOpts?.prefetchAll ?? false;
defaultStrategy ??= defaultOpts?.defaultStrategy ?? 'hover';
// In the future, perhaps we can enable treeshaking specific unused strategies
initTapStrategy();
initHoverStrategy();
initViewportStrategy();
initLoadStrategy();
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does init() do?
init() is a function in the astro codebase, defined in packages/astro/src/prefetch/index.ts.
Where is init() defined?
init() is defined in packages/astro/src/prefetch/index.ts at line 34.
What does init() call?
init() calls 4 function(s): initHoverStrategy, initLoadStrategy, initTapStrategy, initViewportStrategy.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free