MQ
QURASHI
Blog
MQ
MOHAMED QURASHI

© 2026 Mohamed Qurashi. All rights reserved.

Built with precisionDesigned for impactPowered by innovation
MQ
QURASHI
Blog
Back to Blog
Web Development

Next.js Performance Optimization for Images and Fonts

Mohamed Qurashi
April 8, 2026
7 min read
Next.js Performance Optimization for Images and Fonts

Share

TwitterFacebookLinkedIn

Tags

Next.js Performance OptimizationImage OptimizationFont OptimizationPerformance Metrics

A Client Asked Me Something I Couldn't Immediately Answer Last Week. That Pushed Me To Dig Deeper Into Nextjs.


A client recently approached me with a request that wasn't immediately clear from my previous discussions. I realized then that they needed to know how we optimize images, fonts, and Core Web Vitals in our Next.js projects. This led me to dive deeper into these aspects of Next.js performance optimization.


---


Why This Matters (and Why I Care)


Next.js is incredibly powerful for building React apps, but it can become slow if not optimized properly. One crucial aspect that often gets overlooked is the performance of images and fonts. Ensuring these assets load quickly not only improves user experience but also helps in maintaining a good Core Web Vitals score.


Core Web Vitals (CWVs) measure several important metrics about the perceived performance of a website:

1. **CLS** – Cumulative Layout Shift

2. **FID** – First Input Delay

3. **FPS** – FPS (Frames Per Second)

4. **LCP** – Largest Contentful Paint


Improving these CWVs significantly affects how users interact with your app and can even make or break their decision to stay on the page.


The Basics You Actually Need


To optimize Next.js images, I recommend:

  • Using `image: react-img` instead of external images for better performance.
  • Implementing lazy loading using `next/image`.
  • Minimizing image sizes with a library like `react-helmet-image` or custom solutions where necessary.

  • For fonts, it’s important to use `@font-face` properly. Ensure your font files are compressed and placed in the right directory structure.


    How I Build With It (Step by Step)


    1. **Setting Up Image Optimization**

    ```typescript

    // Import React Helmet for setting up image metadata.

    import { MetaTags, Head } from 'next/head';

    import styled from 'styled-components';


    export default function MyApp({ Component, pageProps }) {

    return (

    <>

    <Head>

    <MetaTags />

    </Head>

    {/* Your Next.js component content */}

    <style jsx>{`

    /* Import your fonts here */

    @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap');


    /* Your styled components or styles */

    .my-component {

    font-family: 'Inter', sans-serif;

    color: #333;

    }

    `}</style>

    </>

    );

    }


    // Optionally, you can use React Helmet to set up image metadata.

    const MetaTags = () => <MetaTags />;

    ```


    2. **Lazy Loading Images**

    ```javascript

    import { Fragment } from 'react';

    import Image from 'next/image';


    export default function LazyImageComponent() {

    return (

    <Fragment>

    <div>Content of the component</div>

    <Image src="/path/to/image.png" alt="Description of image" width={300} height={200} loading="eager" />

    {/* You can also use `loading="lazy"` for more advanced lazy loading */}

    </Fragment>

    );

    }

    ```


    Mistakes I Made (So You Don’t Have To)


  • **Lazy Loading Issues**: One of the common mistakes was using lazy loading without ensuring that images are properly cached. This could lead to suboptimal performance.
  • **Font Loading Order**: There were times when fonts didn't load correctly, leading to issues with readability and speed.

  • Advanced Tips From Production


  • **Use External CDN for Dependencies**
  • When dealing with dependencies like external libraries or plugins, it’s important to ensure they are hosted on an external CDN. This not only speeds up loading but also helps in better caching.


  • **Monitor Core Web Vitals**: Tools like Google PageSpeed Insights or tools provided by Next.js can help you monitor and improve your CWVs.

  • My Honest Take


    In summary, optimizing images, fonts, and ensuring good Core Web Vitals are crucial for Next.js performance. It’s a continuous journey that requires attention to detail and practical application of the right solutions. Improving these aspects not only makes your app feel faster but also enhances user satisfaction by keeping their experience positive.


    ---


    *Mohamed Qurashi | Full-Stack Developer at Beyin Digital, Abu Dhabi, UAE | [https://qurashi.dev](https://qurashi.dev)*


    ---

    **Further reading:**

  • [Next.js Performance: Optimizing Images, Fonts & Core Web Vitals — Dev.to](https://dev.to/search?q=Next.js%20Performance%3A%20Optimizing%20Images%2C%20Fonts%20%26%20Core%20Web%20Vitals)
  • [Next.js Performance: Optimizing Images, Fonts & Core Web Vitals — web.dev](https://web.dev/search/?q=Next.js%20Performance%3A%20Optimizing%20Images%2C%20Fonts%20%26%20Core%20Web%20Vitals)

  • **Related articles on this blog:**

  • [nextjs image optimization](/blog/nextjs-image-optimization)
  • [font performance in nextjs](/blog/font-performance-in-nextjs)
  • [corporate performance metrics](/blog/corporate-performance-metrics)

  • Related Articles

    Next.js 15 Complete Guide: App Router & Server Components
    Web Development

    Next.js 15 Complete Guide: App Router & Server Components

    A practical, production-tested guide to Next.js 15 App Router and Server Components. Learn how to cut JavaScript bundles by 40% with real patterns from Beyin Digital.

    App vs Web in Next.js: Why I Finally Switched After 5 Years
    Web Development

    App vs Web in Next.js: Why I Finally Switched After 5 Years

    Discover the real differences between App Router and Pages Router in Next.js. Learn when to use each based on production experience from an SEO specialist in Dubai.