html · level 3 · unit 1 · lesson 1
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
loading="lazy" makes far-off pictures wait their turn.
Professionals care about : how fast a page loads and how smoothly it reacts. Every picture is a , and big pictures are slow ones. A page with twenty photos makes the browser fetch all twenty, even the ones nobody scrolls down to see.
The is the part of the page you can see right now. Add loading="lazy" to an <img> and the browser waits until that picture comes close to the viewport. This is : pictures arrive when people need them.
Never make the first big picture lazy. It is in the viewport from the start, so telling it to wait only slows the page down.
<h1>Bake Street Bakery</h1>
<img src="cake.svg" alt="Our famous lemon drizzle cake">
<h2>Birthday cakes</h2>
<p>Made to order, with your name in icing.</p>
<img src="cake.svg" alt="A birthday cake with five candles" loading="lazy">
<h2>Our garden café</h2>
<img src="tree.svg" alt="The apple tree in our café garden" loading="lazy"> Press show my page to see it here.
Pictures with no loading attribute download straight away. That is right for the first one.
guess first
Which pictures are told to wait?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
<img src="logo.svg" alt="Pip's Plants">
<h1>Plants for every room</h1>
<p>Scroll down to meet this week's favourites.</p>
<img src="tree.svg" alt="A fig tree in a white pot" loading="lazy">
<img src="cat.svg" alt="Moss, our shop cat, asleep by the ferns" loading="lazy">
your turn
Your turn. Make the gallery lazy.
The first picture must load at once. Make the two pictures further down lazy by filling both blanks.
Press show my page to see it here.
- two pictures wait until they are needednot checked yet
- the first picture loads straight awaynot checked yet
fix it
The top picture is told to wait. Can you fix it?
Press show my page to see it here.
- the top picture is not lazynot checked yet
- the garden picture still waitsnot checked yet
- The first picture is the one everyone sees straight away. Should it wait?
- Lazy loading is for pictures far down the page, never the one at the top.
- Delete
loading="lazy"from the picture on line 2, then press run.
nailed it
your pictures wait their turn. :D
- Every picture is a download, and downloads take time.
loading="lazy"waits until a picture nears the viewport.- Never make the first picture people see lazy.
new words in your collection
- performance
- download
- viewport
- lazy loading
This lesson isn’t saved. A free account remembers every lesson you finish.