Loading Resources

Critical Rendering Path

The browser must download and parse HTML and CSS before it can show anything. Scripts in the head without defer block that work. Fast pages:

  • put CSS <link>s in the head,
  • load scripts with defer (or at the end of the body),
  • keep the HTML, CSS and JavaScript small,
  • tell the browser early about important resources.

Resource Hints

<!-- connect early to another origin -->
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>

<!-- download a critical resource early -->
<link rel="preload" href="/fonts/inter.woff2" as="font" type="font/woff2" crossorigin>

<!-- the hero image is the most important image: fetch it first -->
<img src="hero.webp" alt="..." fetchpriority="high" width="1200" height="600">