Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Performance – Preload, Prefetch, and Pr | HTML Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. HTML Course

Lesson 38 of 55

·HTML

Performance – Preload, Prefetch, and Preconnect

10 min

Course progress69%

What you'll learn

Keep these ideas in mind as you work through the lesson.

5 points
  • Differences between `preload`, `prefetch`, and `preconnect`
  • Correct `as` attribute values (`script`, `style`, `image`, `font`)
  • Performance gains for first‑paint metrics (LCP, FCP)
  • Best‑practice limits on the number of preloads
  • Testing resource hints with DevTools

Resource Hints

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>

How they work

  • 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.

Performance tips

  • Use preload sparingly; over‑preloading can block other critical requests.
  • Pair preload with as='font' and crossorigin for web fonts.
  • Use prefetch for resources the user is highly likely to navigate to next.
  • Keep the number of preconnect links low – each initiates a network round‑trip.

Quick checklist for resource hints

  1. Critical CSS preloaded with correct as='style'? ✅
  2. Future navigation assets prefetched (rel='prefetch')? ✅
  3. External origins preconnected (rel='preconnect')? ✅
  4. crossorigin set on fonts and other cross‑origin resources? ✅
  5. No unnecessary preloads that block rendering? ✅

Tip: Verify that your hints are respected using Chrome’s Network panel or the Coverage tool.

Make it stickPractice what you've learned1 quiz · 2 practical tests · Optional activities from HTML CourseBrowse activities
Previous lessonPerformance – Lazy Loading Images & IframesContinue to lesson 39Security – Content Security Policy (CSP)Back to HTML Course curriculum