onPageLoad() — astro Function Reference
Architecture documentation for the onPageLoad() function in index.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD c855800f_f956_d749_63eb_d18456243299["onPageLoad()"] 315e53ea_6d34_137c_ce5c_8c89aca90db9["index.ts"] c855800f_f956_d749_63eb_d18456243299 -->|defined in| 315e53ea_6d34_137c_ce5c_8c89aca90db9 90b6d96b_d7f2_cf1e_695c_fcf15d5c6440["initHoverStrategy()"] 90b6d96b_d7f2_cf1e_695c_fcf15d5c6440 -->|calls| c855800f_f956_d749_63eb_d18456243299 8c99d8e4_b1d5_84e4_ba47_c797c9e87ba9["initViewportStrategy()"] 8c99d8e4_b1d5_84e4_ba47_c797c9e87ba9 -->|calls| c855800f_f956_d749_63eb_d18456243299 f350ee51_b3bd_e845_7222_24e2d4d0756a["initLoadStrategy()"] f350ee51_b3bd_e845_7222_24e2d4d0756a -->|calls| c855800f_f956_d749_63eb_d18456243299 style c855800f_f956_d749_63eb_d18456243299 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/prefetch/index.ts lines 307–319
function onPageLoad(cb: () => void) {
cb();
// Ignore first call of `astro-page-load` as we already call `cb` above.
// We have to call `cb` eagerly as View Transitions may not be enabled.
let firstLoad = false;
document.addEventListener('astro:page-load', () => {
if (!firstLoad) {
firstLoad = true;
return;
}
cb();
});
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does onPageLoad() do?
onPageLoad() is a function in the astro codebase, defined in packages/astro/src/prefetch/index.ts.
Where is onPageLoad() defined?
onPageLoad() is defined in packages/astro/src/prefetch/index.ts at line 307.
What calls onPageLoad()?
onPageLoad() is called by 3 function(s): initHoverStrategy, initLoadStrategy, initViewportStrategy.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free