LayerwiseLayerwise
  • Features
  • Pricing
  • Templates
  • Docs
DownloadDownload
FeaturesPricingTemplatesDocsAI Website BuilderVibe CodingPersonal Software
DownloadDownload
  1. Glossary
  2. /
  3. States & patterns

Lazy loading

Also called lazy load or deferred loading

A technique that waits to load images, videos, or code until they are about to scroll into view, so the first screen loads faster.

import { useState } from 'react';

type Props = {
  src: string;
  preview: string; // a tiny version, about 20px wide
  alt: string;
  width: number;
  height: number;
  eager?: boolean; // true for images in the first screen
};

export function BlurImage({ src, preview, alt, width, height, eager }: Props) {
  const [loaded, setLoaded] = useState(false);

  return (
    // The aspect ratio reserves the space, so nothing shifts while it loads.
    <div
      className='relative overflow-hidden rounded-xl'
      style={{ aspectRatio: `${width} / ${height}` }}
    >
      <img
        src={preview}
        alt=''
        className='absolute inset-0 size-full scale-110 object-cover blur-xl'
      />
      {/* lazy: fetched only when it nears the viewport. */}
      <img
        src={src}
        alt={alt}
        width={width}
        height={height}
        loading={eager ? 'eager' : 'lazy'}
        decoding='async'
        onLoad={() => setLoaded(true)}
        className={`relative size-full object-cover transition-opacity duration-400 ${loaded ? 'opacity-100' : 'opacity-0'}`}
      />
    </div>
  );
}
Lazy-load the gallery: add loading="lazy" with explicit width and height to every image below the fold, show a 20px blurred preview that fills the frame until the full image loads, then fade it to sharp over 400ms. Keep the first row of images eager so the top of the page loads immediately.

Paste into Layerwise or any AI coding tool.

What is Lazy loading?

A long page may hold dozens of images, but a visitor sees only a few at first. Lazy loading fetches each one only when it gets close to the viewport, shortly before it scrolls into view. The first screen loads sooner, and people who never scroll down never download the rest.

For images and iframes, the browser does the work with loading="lazy", and the Next.js next/image component lazy-loads by default. For other content, an IntersectionObserver reports when an element nears the viewport, and a dynamic import() delays loading code until it is needed.

Pair it with a placeholder so the layout doesn’t jump: give each image a width and height (or an aspect-ratio), then show a solid color or a tiny blurred preview that sharpens when the full image arrives, the blur-up technique in the demo. Don’t lazy-load images in the first screen, especially the hero image, because that delays the page’s main content.

Often confused with

Infinite scroll
Infinite scroll adds new items to a list when you reach the end. Lazy loading delays loading things that are already on the page until they near the screen.

Related terms

All terms

Infinite scroll

A list that loads the next batch of items automatically as you scroll near the bottom, so the feed seems to never end.

Skeleton screen

A loading placeholder made of gray blocks shaped like the content on its way, often with a soft shimmer, that the real content replaces.

Perceived performance

How fast an app feels to people, which skeleton screens, instant feedback, and progressive loading can improve even when the real wait stays the same.

Blur

A softening effect made with CSS filter: blur() on an element itself, or backdrop-filter: blur() on whatever shows through it from behind.

Build it with Layerwise

Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.

DownloadDownloadRead the docs
LayerwiseLayerwise

Build full-stack web apps in minutes with AI.

Product

  • Features
  • Pricing
  • Download
  • Templates

Solutions

  • AI Website Builder
  • Vibe Coding
  • Personal Software

Resources

  • Documentation
  • Changelog
  • Blog
  • Vibe Coding Glossary
  • llms.txt
  • llms-full.txt

Company

  • About
  • Contact

Legal

  • Privacy
  • Analytics Privacy
  • Terms
  • Security
  • Abuse

© 2026 Layerwise. All rights reserved.

Entrances & exits

  • Fade in
  • Slide in
  • Scale in
  • Pop in
  • Blur in
  • Reveal animation
  • Enter and exit animations

Timing & sequencing

  • Duration
  • Delay
  • Keyframes
  • Tweening
  • Stagger
  • Orchestration
  • Fill mode
  • Stepped animation
  • Looping animation
  • Yoyo animation

Easing

  • Easing
  • Linear easing
  • Ease-in
  • Ease-out
  • Ease-in-out
  • Cubic-bezier
  • Asymmetric easing
  • Overshoot easing

Springs & physics

  • Spring animation
  • Stiffness
  • Damping
  • Mass
  • Bounce
  • Velocity
  • Momentum
  • Interruptible animation
  • Rubber-banding

Transforms

  • Translate
  • Scale
  • Rotate
  • Skew
  • 3D flip
  • Perspective
  • Transform origin
  • Origin-aware animation

State transitions

  • Crossfade
  • Morph
  • Shared element transition
  • Layout animation
  • Height auto animation
  • Direction-aware transition
  • Continuity transition
  • Page transition
  • View Transitions API

Scroll effects

  • Scroll reveal
  • Scroll-driven animation
  • Parallax scrolling
  • Scrollytelling
  • Scroll pinning
  • Horizontal scroll section
  • Scroll progress bar
  • Scroll snap
  • Smooth scrolling

Interaction feedback

  • Hover effect
  • Press feedback
  • Ripple effect
  • Shake animation
  • Hold to confirm
  • Drag gesture
  • Drag to reorder
  • Swipe to dismiss
  • Pull to refresh
  • Magnetic button
  • Custom cursor
  • 3D tilt card
  • Spotlight card

Text effects

  • Typewriter effect
  • Text scramble
  • Split text animation
  • Text morph
  • Rotating words
  • Gradient text
  • Shimmer text
  • Number ticker
  • Tabular numbers
  • Underline animation

Loops & ambient motion

  • Marquee
  • Pulse animation
  • Float animation
  • Orbit animation
  • Idle animation
  • Particle background
  • Border beam
  • Confetti
  • Animated gradient

Visual effects

  • Blur
  • Clip-path
  • Mask
  • Before/after slider
  • SVG line drawing
  • Lottie animation

Motion principles

  • Purposeful animation
  • Anticipation
  • Follow-through
  • Squash and stretch
  • Perceived performance
  • Frequency of use
  • Spatial consistency
  • Reduced motion

Animation performance

  • Frame rate (FPS)
  • Jank
  • GPU acceleration
  • will-change
  • Layout thrashing

Layout

  • Hero section
  • Above the fold
  • Sticky header
  • Sidebar
  • Bento grid
  • Card
  • Flexbox
  • CSS Grid
  • Padding vs margin
  • Responsive design
  • Container
  • Masonry layout
  • Split screen
  • Z-index
  • Overflow

Components

  • Button variants
  • Modal
  • Drawer
  • Popover
  • Tooltip
  • Dropdown menu
  • Context menu
  • Toast notification
  • Tabs
  • Segmented control
  • Accordion
  • Carousel
  • Command palette
  • Combobox
  • Toggle switch
  • Checkbox
  • Radio button
  • Date picker
  • Breadcrumb
  • Pagination
  • Infinite scroll
  • Badge
  • Avatar stack
  • Empty state
  • Skeleton screen
  • Spinner
  • Progress bar
  • Data table
  • Stepper
  • Floating label
  • Inline validation
  • Alert banner
  • Tag input

States & patterns

  • Interaction states
  • Focus ring
  • Loading state
  • Optimistic UI
  • Debounce
  • Lazy loading
  • Dark mode
  • Micro-interaction
  • Affordance
  • Undo
  • Drag and drop
  • Keyboard shortcut

Visual styles

  • Glassmorphism
  • Liquid glass
  • Neumorphism
  • Claymorphism
  • Neo-brutalism
  • Skeuomorphism
  • Flat design
  • Mesh gradient
  • Aurora background
  • Grain texture
  • Glow effect
  • Drop shadow
  • Border radius
  • Grid background
  • Typographic hierarchy
  • Accent color
  • Color contrast

Vibe coding & AI

  • Vibe coding
  • Prompt
  • Context window
  • Token
  • AI agent
  • Tool call
  • Hallucination
  • Diff
  • Live preview
  • Checkpoint
  • Git commit
  • Deploy
  • Frontend and backend
  • API
  • Database
  • Rules file
  • MCP
  • Plan mode
  • Visual edit
0 of 12 requested
Mountains and pine trees reflected in a still lake
Mountain lake
People crossing a bright, sign-covered street in Tokyo
Tokyo crossing
A sand dune ridge under a clear blue sky
Desert dunes
Green northern lights over snowy peaks
Northern lights
Palm trees leaning over a white beach and turquoise water
Palm beach
Fog drifting over a forested valley
Misty forest
Hot air balloons drifting over a rocky valley
Hot air balloons
Neon signs glowing over a city street at night
Neon street
Snow-covered Ama Dablam rising above a mountain range in Nepal
Ama Dablam
A winding road through yellow and orange trees, seen from above
Autumn road
Turquoise surf breaking on a sandy shore, seen from above
Ocean shore
A dense carpet of red, yellow, and white flowers
Flower field