Resource Preloading Cheat Sheet

Webdev, HTML, Browser · Oct 12, 2022

Preloading content is one of many ways to improve web performance. The rel attribute of the link element can be used to instruct the browser how to handle different resources. Here's a handy cheatsheet to help you remember the different values and their effects.

  • rel="preload": Download the resource as soon as possible. Used when you're going to need a resource in a few seconds, on the same page.
  • rel="prefetch": Suggest that the resource is fetched in advance. Used when you're going to need a resource for the next page.
  • rel="preconnect": Establish a connection to the linked website, to speed up fetching resources from it later. Used when you're going to need a resource, but you don't know its full URL yet.
  • rel="dns-prefetch": Resolve the DNS for the linked website, to speed up fetching resources from it later. Used when you're going to need a resource, but you don't know its full URL yet (mainly for older browsers).
  • rel="prerender": Preload the resource and render it in the background, speeding up page load in the future. Used when users are likely to navigate to a specific page.
  • rel="modulepreload": Preload a JavaScript module script. Used when you're going to need an ES module script soon.

Written by Angelos Chalaris

I'm Angelos Chalaris, a JavaScript software engineer, based in Athens, Greece. The best snippets from my coding adventures are published here to help others learn to code.

If you want to keep in touch, follow me on GitHub or Twitter.

More like this

  • Cheatsheets

    A collection of cheatsheets to bookmark and come back to whenever you need to look up anything.

    Collection · 15 snippets

  • Tip: Prefetching resources in the browser

    Resource prefetching is a great technique to improve perceived page speed on your website and one that requires little to no effort. Learn how to use it today.

    HTML, Webdev · Jun 12, 2021

  • Recommended HTML head icon tags

    Ensure your HTML documents have a proper favicon by including these lines in your <head> element.

    HTML, Webdev · Jan 24, 2023

  • Recommended HTML head links

    Make your HTML documents more SEO-friendly by including these lines in your <head> element.

    HTML, Webdev · Jan 26, 2023