canPrefetchUrl() — astro Function Reference
Architecture documentation for the canPrefetchUrl() function in index.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD ea9541b4_bd9d_6d4f_5137_70ec3d7865b1["canPrefetchUrl()"] 315e53ea_6d34_137c_ce5c_8c89aca90db9["index.ts"] ea9541b4_bd9d_6d4f_5137_70ec3d7865b1 -->|defined in| 315e53ea_6d34_137c_ce5c_8c89aca90db9 1502f987_7806_fcef_2f8e_55d799080686["prefetch()"] 1502f987_7806_fcef_2f8e_55d799080686 -->|calls| ea9541b4_bd9d_6d4f_5137_70ec3d7865b1 fa17c239_9e46_24a4_170f_6c1482c21778["isSlowConnection()"] ea9541b4_bd9d_6d4f_5137_70ec3d7865b1 -->|calls| fa17c239_9e46_24a4_170f_6c1482c21778 style ea9541b4_bd9d_6d4f_5137_70ec3d7865b1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/prefetch/index.ts lines 250–265
function canPrefetchUrl(url: string, ignoreSlowConnection: boolean) {
// Skip prefetch if offline
if (!navigator.onLine) return false;
// Skip prefetch if using data saver mode or slow connection
if (!ignoreSlowConnection && isSlowConnection()) return false;
// Else check if URL is within the same origin, not the current page, and not already prefetched
try {
const urlObj = new URL(url, location.href);
return (
location.origin === urlObj.origin &&
(location.pathname !== urlObj.pathname || location.search !== urlObj.search) &&
!prefetchedUrls.has(url)
);
} catch {}
return false;
}
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does canPrefetchUrl() do?
canPrefetchUrl() is a function in the astro codebase, defined in packages/astro/src/prefetch/index.ts.
Where is canPrefetchUrl() defined?
canPrefetchUrl() is defined in packages/astro/src/prefetch/index.ts at line 250.
What does canPrefetchUrl() call?
canPrefetchUrl() calls 1 function(s): isSlowConnection.
What calls canPrefetchUrl()?
canPrefetchUrl() 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