Lesson 4 of 8

Images that don't slow the page down

Goal

Four attributes that cut the cost of images

01

Explanation

Images are the heaviest part of most pages, and four attributes solve most of the problem:

loading="lazy" delays loading images that are off screen, decoding="async" keeps image decoding from holding up the page's rendering, and width and height reserve the space ahead of time so the text doesn't jump when the image arrives. That jump is what the CLS metric measures.

An important exception: don't lazy-load the first image that's visible as soon as the page opens. Lazy-loading it holds back the largest element on the page and hurts your LCP score instead of improving it.

02

Your task

Make the first image load right away and the rest lazily, let every image decode asynchronously, and give each one dimensions and alt text.

Checks

5 checks
  1. Every image has alt text that describes it
  2. Every image has width and height
  3. The second and third images are lazy-loaded
  4. The first image isn't lazy-loaded
  5. Every image decodes asynchronously
03

Hints

0/3
Track lessons0 of 8 done

Find out where your page really loses time, and how to win it back by adding elements in one go, making fewer calls and never computing the same thing twice.

Advanced level, 8 lessons, 1.5 hours in total.

index.html
Preview
index.html100%
–/5

Press “Run and check” to grade your code.

5 checks listed under “Your task”.

Track lessons0 of 8 done

Find out where your page really loses time, and how to win it back by adding elements in one go, making fewer calls and never computing the same thing twice.

Advanced level, 8 lessons, 1.5 hours in total.