Lesson 38 of 55
HTMLPerformance – Preload, Prefetch, and Preconnect
10 min
Course progress69%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 38 of 55
HTML10 min
Keep these ideas in mind as you work through the lesson.
Guide the browser to fetch critical assets earlier.
<!-- Preload critical CSS -->
<link rel='preload' href='styles/main.css' as='style' onload='this.rel="stylesheet"'>
<!-- Prefetch a page the user might visit next -->
<link rel='prefetch' href='/about.html'>
<!-- Preconnect to third‑party CDN -->
<link rel='preconnect' href='https://fonts.gstatic.com' crossorigin>
preload – Loads the resource immediately and makes it available for use as soon as it’s needed; must specify the as attribute (script, style, font, image).prefetch – Low‑priority fetch for resources likely needed later (e.g., next article).preconnect – Opens early DNS resolution, TLS handshake, and TCP connection to an external origin.preload sparingly; over‑preloading can block other critical requests.preload with as='font' and crossorigin for web fonts.prefetch for resources the user is highly likely to navigate to next.preconnect links low – each initiates a network round‑trip.as='style'? ✅rel='prefetch')? ✅rel='preconnect')? ✅crossorigin set on fonts and other cross‑origin resources? ✅Tip: Verify that your hints are respected using Chrome’s Network panel or the Coverage tool.