Frontend Patterns

Pattern

Skeleton Loading

Show placeholder content that mimics the layout of incoming data for perceived performance.

Performance Advanced

Skeleton Loading

Problem

Blank screens or generic spinners during data loading make applications feel sluggish and unresponsive. Users have no sense of what content is coming or how the page will look, creating uncertainty and frustration. The sudden appearance of content causes jarring layout shifts that disrupt the reading experience.

Solution

Show placeholder shapes that mimic final content layout while data loads. This provides immediate visual feedback and prevents layout shifts when content arrives.

Example

This demonstrates showing placeholder shapes that mimic the final content layout during data loading, improving perceived performance and preventing layout shifts when real content arrives.

// Skeleton component that mimics final card layout
function SkeletonCard() {
  return (
    <div className="skeleton">
      <div className="skeleton-title" />      {/* Placeholder for title */}
      <div className="skeleton-text" />       {/* Placeholder for text line 1 */}
      <div className="skeleton-text" />       {/* Placeholder for text line 2 */}
    </div>
  );
}

// Show skeleton while loading, real card when data arrives
{isLoading ? <SkeletonCard /> : <Card data={data} />}

Benefits

  • Improves perceived performance by showing immediate visual feedback.
  • Prevents jarring layout shifts when actual content loads.
  • Provides users with a sense of what’s coming and how long to wait.
  • Creates a more polished loading experience than generic spinners.

Tradeoffs

  • Requires creating and maintaining skeleton components for each layout.
  • Can feel misleading if loading takes much longer than expected.
  • Adds complexity with conditional rendering between skeletons and real content.
  • May not accurately represent final content if structure varies significantly.
Stay Updated

Get New Patterns
in Your Inbox

Join thousands of developers receiving weekly insights on frontend architecture patterns

No spam. Unsubscribe anytime.