Course contentsShow
← Web Development
Lesson 1965 of 2,98236. Performance Optimization TechniquesFree lesson

Preload for Critical Resources

Prioritize critical resources by forcing early discovery and download with preload for current page needs.

What You'll Learn

You'll learn how to use <link rel="preload"> to force the browser to discover and download critical resources immediately, improving page load performance for assets needed on the current page.

The Critical Resource Problem

When a browser loads your page, it doesn't know which resources are truly critical until it parses the entire HTML, CSS, and sometimes even JavaScript. By then, valuable time has been lost. Late-discovered fonts, hero images, or critical scripts can delay your Largest Contentful Paint (LCP) and hurt user experience.

Preload tells the browser: "Download this resource NOW—you'll need it on this page very soon."

How Preload Works

Use the <link rel="preload"> tag in your HTML <head>:

<link rel="preload" href="/fonts/main-font.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/hero-image.jpg" as="image">
<link rel="preload" href="/critical-style.css" as="style">
<link rel="preload" href="/app-bundle.js" as="script">

The as attribute tells the browser what type of resource it is, so it can prioritize correctly. The crossorigin attribute is required for fonts, even same-origin ones.

When to Use Preload

Preload is for current-page critical resources that are:

  • Late-discovered (fonts in CSS, background images, dynamically loaded scripts)
  • Essential for above-the-fold rendering
  • Blocking LCP or user interaction

Don't preload everything—that defeats the purpose and can actually harm performance by competing with other critical resources.

Analogy

Think of preload like calling ahead to a restaurant: "I'll be there in 10 minutes—start preparing my order now." Without preload, you arrive, order, then wait for cooking to start.

Key Takeaway:
Use <link rel="preload"> to force early discovery and download of critical resources needed immediately on the current page, reducing LCP and improving perceived performance.