FE5: Loading less, loading later

Lesson 2 of 5 ยท reading 15โ€“25 minutes; practice and project time is on the module page

Lazy loading below the fold

๐ŸŽฏYou'll be able to

Lazy-load content and components that sit below the fold, without hurting the first view.

๐Ÿ The everyday picture

A long train doesn't need all its lights on in every coach at a station; lights come on as people board each coach. A long page can load its lower sections as people scroll towards them.

๐Ÿ“˜What it really is

๐Ÿ“A worked example

Kirana's home page has a hero banner, then twelve category rows with 20 product images each:

Approach Images downloaded on first view Data used if the visitor doesn't scroll
Everything at once 241 3.1 MB
Lazy-load all below the first two rows 41 0.6 MB

The hero banner and the first two rows stay eager and prioritised; the rest load as the customer scrolls, with fixed-size placeholders.

๐ŸŒWhere it's used

๐Ÿ“Case scenario

After a developer adds loading="lazy" to every image on the site "for speed", LCP on product pages gets worse. The main product photo is now lazy-loaded. Removing the attribute from the first-screen images, and adding priority to the product photo, fixes LCP while keeping the data savings below the fold.

๐Ÿ–ฑ๏ธTry it

Count the images your Kirana home page downloads without scrolling. Lazy-load everything below the first screen with reserved space, keep the first screen eager, and record images and data before and after.

โš ๏ธCommon mistakes

๐Ÿ› ๏ธFor your project

In Project 3, keep the hero and first row of deals loading early, and lazy-load the rest.

โœ…Quick check

Which images shouldn't be lazy-loaded?

Show the answer

The LCP image and anything visible in the first screen.

Why load lazy content slightly before it becomes visible?

Show the answer

So it's ready by the time the person scrolls to it.

โ† PreviousWhat's in your bundle, and splitting it
ProLearners Assist