#1 Data Analytics Program in India
₹2,499₹1,499Enroll Now
5 min read
•Question 48 of 49medium

What is Link Prefetch and Preload?

Resource loading hints.

What You'll Learn

  • Resource loading hints
  • Preload vs prefetch
  • Performance optimization

Resource Hints

HintPurpose
preloadCritical resources for current page
prefetchResources for future navigation
preconnectEarly connection to origins
dns-prefetchDNS lookup only

Examples

index.htmlHTML
<head>
  <!-- Preload: Critical for current page -->
  <link rel="preload" href="/fonts/main.woff2" as="font" crossorigin>
  <link rel="preload" href="/css/critical.css" as="style">

  <!-- Prefetch: Likely needed for next navigation -->
  <link rel="prefetch" href="/next-page.html">

  <!-- Preconnect: Early connection -->
  <link rel="preconnect" href="https://api.example.com">

  <!-- DNS Prefetch: Just DNS lookup -->
  <link rel="dns-prefetch" href="https://analytics.example.com">
</head>

Best Practices

  • Use preload for fonts, critical CSS, hero images
  • Use prefetch for likely next-page resources
  • Don't over-use - it can waste bandwidth