6 Ways To Improve Web Performance With Preload Content

prefetch vs preload vs preconnect vs dns-prefetch vs prerender vs modulepreload

*advanced javascript techniques*

🧵 Thread... Image
1. preload

<link rel="preload"> tells the browser to download and cache a resource (script or stylesheet) as soon as possible

It’s helpful when you need that resource a few seconds after loading the page
2. prefetch

<link rel="prefetch"> tells browser to download and cache a resource in the background

The download happens with a low priority, so it doesn’t interfere with more important resources

It’s helpful when you need resource on a subsequent page
3. preconnect

<link rel="preconnect"> tells browser to perform a connection to a domain in advance

It’s helpful when you download something from that domain soon, but you don’t know what exactly, and you want to speed up the initial connection
4. dns-prefetch

<link rel="dns-prefetch"> tells browser to perform a DNS resolution of a domain in advance

It’s helpful when you connect to that domain soon, and you want to speed up the initial connection
5. prerender

<link rel="prerender"> tells browser to load a URL and render it in an invisible tab

When a user clicks on a link, the page should be rendered immediately

It’s helpful when you’re sure user will visit a specific page next, and you want to render it faster
6. modulepreload

<link rel="modulepreload"> tells browser to download, cache, and compile a JS module script as soon as possible

It’s helpful when you use ES modules in production, and you want to load your app faster
TLDR;

preload – you need a resource in a few seconds

prefetch – you need a resource for the next page

preconnect – you need a resource soon, but you don’t know its full url yet
dns-prefetch – you need a resource soon, but you don’t know its full url yet (for older browsers)

prerender – you’re certain users will navigate to a specific page, and you want to speed it up

modulepreload – you’re need an ES module script soon
Thanks for reading!

❤️ and share this thread if you found it helpful.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Nick Bull JS

Nick Bull JS Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @nickbulljs

19 Oct
Complete Guide How To Code Review

Best practices from Google, Apple, Facebook, and Amazon

🧵 Thread 🧵

#100DaysOfCode
Let's start with the question:

What’s the end goal of the code review?

The primary purpose of the code review is to make sure that the solution is solving the problem in the best possible way. From the code and product perspective.
But how do you determine if the solution you are reviewing is the best way to solve the problem? In other words, how to code review?

Let’s deep dive into it.
Read 23 tweets
18 Oct
10 Interview Questions Every JavaScript Developer Should Know

🧵 Thread...
1. Name two programming paradigms important for JavaScript?

JavaScript is a multi-paradigm language, supporting imperative/procedural programming along with OOP (Object-Oriented Programming) and functional programming
2. What is functional programming?

Functional programming produces programs by composing mathematical functions and avoids shared state & mutable data
Read 12 tweets
15 Sep
21 Must-Read Books For Programmers

(become a Senior Developer in a year)

🧵 Thread...
1/ Personal Effectiveness

- The 7 Habits of Highly Effective People: Powerful Lessons in Personal Change
- Great at Work: How Top Performers Do Less, Work Better, and Achieve More
- The Checklist Manifesto: How to Get Things Right
2/ Writing Code

- Code Complete
- Clean Code: A Handbook of Agile Software Craftsmanship
- Code Simplicity: The Fundamentals of Software
Read 8 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!