Mohamed GhoniemWeb Developer
MohamedGhoniem
  • Work
  • Services
  • Experience
  • Blog
Available
CV
Open to opportunities
WorkServicesExperienceBlogDownload CV
All blogs

© 2026 Mohamed Ghoniem. All rights reserved.

TwitterGitHubLinkedIn
The hidden cost of unoptimized images in Next.js
DesignFrontend
All blogs

The hidden cost of unoptimized images in Next.js

MG
Mohamed Ghoniem
·July 16, 2026·5 min read

Prefer to watch?

This article has a full video walkthrough on YouTube

Watch the same walkthrough on YouTube.

Why image optimization is critical

On a typical webpage, images make up over 60% of the total page weight. When users land on your site, unoptimized images cause massive Layout Shifts (CLS), high LCP times, and unnecessary data usage, especially on mobile networks.

The power of next/image

The Next.js Image Component extends the HTML <img> element with features for automated performance optimization:

  1. Size Optimization: Automatically serves correctly sized images for each device, using modern image formats like WebP and AVIF.
  2. Visual Stability: Prevents layout shift automatically when images are loading.
  3. Faster Page Loads: Images are only loaded when they enter the viewport using native browser lazy loading, with optional blur-up placeholders.
jsx
import Image from 'next/image'

export default function Profile() {
  return (
    <Image
      src="/me.png"
      alt="Author"
      width={500}
      height={500}
      priority // Use priority for above-the-fold content!
    />
  )
}

Advanced Optimization Tips

Always define the sizes attribute. It tells the browser how wide the image will render at different breakpoints so it doesn't load a huge file for a small thumbnail on mobile screens.

On this page5 min left
Why image optimization is criticalThe power of next/imageAdvanced Optimization Tips

Share

On this page5 min left
Why image optimization is criticalThe power of next/imageAdvanced Optimization Tips

Written by

Mohamed Ghoniem

I build fast, responsive web experiences, from pixel-perfect UI to the backend behind it.

Get in touchAll posts
Older postJWT refresh token rotation — the right wayNewer postBuilding a design system from scratch with Figma tokens & Tailwind
Keep reading
Building a design system from scratch with Figma tokens & Tailwind
DesignFrontendJuly 16, 2026

Building a design system from scratch with Figma tokens & Tailwind

A practical walkthrough of how I set up a token-driven design system that stays in sync between Figma and code — no plugin lock-in, no manual updates.

MG
Mohamed G.
8 min read
JWT refresh token rotation — the right way
DesignFrontendJuly 16, 2026

JWT refresh token rotation — the right way

A practical walkthrough of how I set up a token-driven design system that stays in sync between Figma and code — no plugin lock-in, no manual updates.

MG
Mohamed G.
6 min read
Smooth page transitions with Framer Motion and Next.js App Router
DesignFrontendJuly 16, 2026

Smooth page transitions with Framer Motion and Next.js App Router

A practical walkthrough of how I set up a token-driven design system that stays in sync between Figma and code — no plugin lock-in, no manual updates.

MG
Mohamed G.
7 min read