Serksa
All Concepts
Frontend Architecture

Lazy Loading

1

What is it?

<strong>Lazy loading</strong> is deferring the loading of resources (images, components, code) until they're actually needed. It improves initial page load time and reduces bandwidth usage.

2

Think of it like...

The Restaurant Menu Analogy

Restaurants don't cook all dishes upfront. They prepare food when you order it. Lazy loading works the sameβ€”load resources when needed, not all at once.

πŸ“–

Menu (Page)

What you see first

πŸ•

Food (Resources)

Loaded when ordered

πŸ‘¨β€πŸ³

Kitchen (Server)

Prepares on demand

3

Visual Flow

🌐Page Load

Initial Content

β†’
πŸ‘οΈUser Scrolls

Resource Needed

β†’
⚑Load Resource

Just in Time

4

Where you see it

1

Page loads

Only above-the-fold content loads

2

User scrolls down

Images below fold come into view

3

Trigger loading

Intersection Observer detects visibility

4

Load resource

Fetch image/component from server

5

Display content

Show loaded resource to user

5

Common Mistake

❌

Wrong

"Lazy load everything for best performance"

βœ…

Correct

<strong>Lazy load strategically</strong>. Don't lazy load above-the-fold content or critical resources. Focus on below-the-fold images, heavy components, and routes.

πŸ’‘ Real-World Example

Image-heavy blog:

1

Without lazy loading: Load all 50 images (10MB, 5s load time)

2

With lazy loading: Load 5 visible images (1MB, 1s load time)

3

As user scrolls, load more images on demand

4

Result: 5x faster initial load, better user experience