html · level 3 · unit 2 · lesson 3
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
rel="preconnect" gets another server ready early.
Pages often use files from other servers, like maps, videos or pictures. Each server has a , its name in the URL, like example.com. Before the first file can travel, the browser must find the server and set up a .
Finding the server uses , the internet's address book. Then a few messages go back and forth to make the connection safe. All of that takes time, and nothing downloads until it is done.
<link rel="preconnect"> does the work early, while the browser is busy with your page. rel="dns-prefetch" is a lighter hint that only does the DNS lookup. Preconnect to the one or two domains that matter most.
<!doctype html>
<html lang="en">
<head>
<title>Find our shop</title>
<link rel="preconnect" href="https://example.com">
<link rel="dns-prefetch" href="https://example.com">
</head>
<body>
<h1>Find our shop</h1>
<p>Our map comes from another server, so the browser connects early.</p>
</body>
</html> Press show my page to see it here.
Writing both for one domain is a common habit: browsers that skip preconnect still do the lookup.
guess first
What does the preconnect download?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
<head>
<title>Gig listings</title>
<link rel="preconnect" href="https://example.com">
</head>
<body>
<h1>Gigs this week</h1>
</body>
your turn
Your turn. Warm up the video server.
The videos on this page come from https://example.com. On line 5, preconnect to it by filling rel and href.
Press show my page to see it here.
- the link warms up a connectionnot checked yet
- it names the video server's domainnot checked yet
fix it
The preconnect goes to the wrong place. Can you fix it?
Press show my page to see it here.
- the preconnect names a full addressnot checked yet
- there is still one preconnectnot checked yet
- Without
https://, the browser reads the address as a file called example.com on your own server. - A preconnect needs the start of a full URL:
https://and then the domain. - Change
href="example.com"tohref="https://example.com"on line 5, then press run.
nailed it
the connection is ready and waiting. :D
- Every new domain needs a lookup and a connection first.
rel="preconnect"does that work early.- Preconnect only to the one or two domains that matter.
new words in your collection
- domain
- connection
- DNS
This lesson isn’t saved. A free account remembers every lesson you finish.