SoDeep IconSoDeep
·
The way a website only loads images as you scroll

The way a website only loads images as you scroll

@Nan_Binary · June 20, 2026

Websites used to be like over-eager hosts, shoving a twelve-course meal at you the second you stepped inside. Now, they use a bit of sensible restraint called lazy loading.

It is like a picnic by the shore. You do not unwrap every single sandwich at once for the seagulls to eye; you only pop the lid when someone is actually ready to take a bite.

Your browser waits until an image is about to scroll into view before fetching it. This keeps the page from lagging like a rusty bicycle and saves your data from being wasted on content you might never even look at.

But how does the browser know exactly when to start fetching?

It’s not psychic, dear. It uses a digital tripwire. Think of a shopkeeper by the window; they don't start bagging the scones until they see your car pull into the driveway.

The browser monitors the distance between the image's 'placeholder' and the edge of your screen. Once that gap narrows, it sends a signal to the server to hurry up and deliver.

It’s a gamble, though. If you scroll like a maniac, you’ll catch the site with its trousers down—seeing a blank box for a split second before the picture catches up.

So what's actually holding that empty spot open in the meantime?

Think of it like putting your beach towel on a sun lounger at dawn. You aren't sitting there yet, but you've staked your claim so nobody else tries to squeeze into your spot.

Without that placeholder, the browser wouldn't know how much room to leave. When the image finally arrives, it would shove all the text down, making you lose your place like a gust of wind blowing away your newspaper.

Developers hard-code the dimensions into the site's skeleton. This bit of pre-planning keeps the layout steady while the server finishes its tea and finally delivers your picture.

Wait, how do they know the size before the photo even exists?

It’s like ordering a picture frame before the artist has even touched the canvas. You don't need to see the colors to know the dimensions.

The server sends a tiny 'whisper' of data called metadata first. It’s like a luggage tag; it tells the browser the size of the trunk before you even unpack it.

If they don't know, they just force a standard shape. It’s better to have a slightly ill-fitting towel than to have the whole beach shift when the guest finally arrives, don't you think?

Who's responsible for scribbling those dimensions onto the file in the first place?

It’s not some intern with a ruler, darling. When a photo is 'born'—whether you click a shutter or save a design—the software automatically stitches those dimensions into the file's header. It’s like a birth certificate that stays with the image forever.

The server doesn't need to 'look' at the actual picture to find them. It just peeks at that tiny header, much like checking the size tag on a coat without having to try the whole thing on.

If that tag is missing, the browser is left playing a guessing game. It’s a bit like trying to bake a cake when the recipe forgets to mention the size of the tin—you're likely to end up with a messy overflow.

Explore in card mode →

Related topics

How a computer uses 'queues' to handle information in orderThe logic of 'database indexing' for finding information quicklyThe way a computer screen uses pixels to display imagesThe way 'responsive design' makes a website fit any screen sizeThe logic of 'pathfinding algorithms' for navigating digital mapsThe way a computer uses 'encryption' to keep messages private