Prefetching in Astro means loading resources or pages in the background before the user clicks on them. This helps the site feel faster because the content is ready when needed.
Click to reveal answer
intermediate
How does preloading differ from prefetching?
Preloading tells the browser to load important resources immediately, so they are ready to use right away. Prefetching loads resources with low priority for future use.
Click to reveal answer
beginner
Which HTML tag attribute is commonly used for preloading resources?
The <link rel="preload" href="..." as="..."> tag is used to preload resources like scripts, styles, or fonts.
Click to reveal answer
beginner
Why is prefetching useful in Astro projects?
Prefetching helps Astro sites load pages faster by downloading linked pages or data in the background before the user visits them, improving user experience.
Click to reveal answer
intermediate
Name one way to enable prefetching in Astro.
You can add the prefetch attribute to <a> tags to tell Astro to prefetch the page when the user hovers or is likely to visit.
Click to reveal answer
What does prefetching do in Astro?
ARemoves unused resources from the page
BLoads resources in the background before user action
CDelays loading resources until user clicks
DBlocks page rendering until resources load
✗ Incorrect
Prefetching loads resources quietly in the background before the user needs them.
Which rel attribute is used to preload resources?
Apreload
Bprefetch
Cstylesheet
Dmodule
✗ Incorrect
The rel="preload" attribute tells the browser to load resources immediately.
How do you enable prefetching on an Astro link?
AAdd <code>client:visible</code>
BAdd <code>client:idle</code>
CAdd <code>client:load</code>
DAdd <code>prefetch</code>
✗ Incorrect
The prefetch attribute enables prefetching for Astro links.
What is the main benefit of preloading?
ATo load important resources early for faster use
BTo load resources only when needed
CTo delay resource loading to save bandwidth
DTo cache resources permanently
✗ Incorrect
Preloading loads key resources early so they are ready when the page needs them.
Which is true about prefetching?
AIt blocks page rendering
BIt loads resources with high priority
CIt loads resources with low priority for future use
DIt removes unused CSS
✗ Incorrect
Prefetching loads resources with low priority to prepare for future navigation.
Explain in your own words how prefetching improves user experience in Astro projects.
Think about what happens before the user clicks a link.
You got /4 concepts.
Describe the difference between preloading and prefetching and when you might use each.
Consider resource priority and timing.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of prefetching in Astro?
easy
A. To remove unused resources from the page
B. To load resources immediately for current use
C. To load resources in the background before they are needed
D. To delay loading resources until user interaction
Solution
Step 1: Understand prefetching concept
Prefetching means loading resources quietly in the background before the user needs them.
Step 2: Compare with other options
Preloading loads immediately, delaying is opposite, and removing resources is unrelated.
Final Answer:
To load resources in the background before they are needed -> Option C
Quick Check:
Prefetching = background loading [OK]
Hint: Prefetching = load early but quietly in background [OK]
Common Mistakes:
Confusing prefetching with preloading
Thinking prefetching delays loading
Assuming prefetching removes resources
2. Which is the correct way to add a prefetch link in Astro's <head>?
easy
A.
B.
C.
D.
Solution
Step 1: Identify correct rel attribute for prefetch
Prefetch uses rel="prefetch" to hint browser to load resource in background.
Step 2: Check other options
Preload uses rel="preload", but question asks for prefetch. rel="fetch" is invalid.
Final Answer:
<link rel="prefetch" href="/script.js"> -> Option D
Quick Check:
Prefetch link uses rel="prefetch" [OK]
Hint: Prefetch link uses rel="prefetch" exactly [OK]
Common Mistakes:
Using preload instead of prefetch
Missing the rel attribute
Using invalid rel values like fetch
3. Given this Astro component snippet, what will happen?