<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ayorinde Oluwasina</title>
    <description>The latest articles on DEV Community by Ayorinde Oluwasina (@ayuse).</description>
    <link>https://dev.to/ayuse</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F809970%2F793deeab-337c-49a6-819f-398e41652cc2.jpg</url>
      <title>DEV Community: Ayorinde Oluwasina</title>
      <link>https://dev.to/ayuse</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ayuse"/>
    <language>en</language>
    <item>
      <title>Optimizing Your Next.js Website: A Guide to Google Core Web Vitals</title>
      <dc:creator>Ayorinde Oluwasina</dc:creator>
      <pubDate>Tue, 30 Jan 2024 22:53:01 +0000</pubDate>
      <link>https://dev.to/ayuse/optimizing-your-nextjs-website-a-guide-to-google-core-web-vitals-5a85</link>
      <guid>https://dev.to/ayuse/optimizing-your-nextjs-website-a-guide-to-google-core-web-vitals-5a85</guid>
      <description>&lt;p&gt;In today's world of web development, delivering a seamless and efficient user experience is critical. Google Core Web Vitals has emerged as a crucial set of metrics to assess and optimize websites. In this article, we'll delve into what Core Web Vitals are, why they matter, and provide simple ways to enhance them for your Next.js project.&lt;/p&gt;

&lt;h1&gt;
  
  
  Understanding Google Core Web Vitals
&lt;/h1&gt;

&lt;p&gt;Core Web Vitals can be broken down into three main aspects&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Largest Contentful Paint (LCP)&lt;/li&gt;
&lt;li&gt;First Input Delay (FID)&lt;/li&gt;
&lt;li&gt;Cumulative Layout Shift (CLS)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx92nwpjm7wot9h0vlefs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx92nwpjm7wot9h0vlefs.png" alt="Google Core Web Vitals" width="800" height="459"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Largest Contentful Paint (LCP)
&lt;/h2&gt;

&lt;p&gt;LCP measures the time it takes for the main content of a page to load. It should ideally occur within 2.5 seconds of when the page first starts loading.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flknm4yw90p6f3232xcy3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flknm4yw90p6f3232xcy3.png" alt="Largest Contentful Paint (LCP)" width="800" height="459"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Major Causes of Poor LCP&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F72577fpbhim9n42njc53.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F72577fpbhim9n42njc53.png" alt="Major Causes of Poor LCP" width="800" height="465"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How can we improve LCP in Nextjs&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Optimize images using &lt;code&gt;next/image&lt;/code&gt; tag.&lt;/li&gt;
&lt;li&gt;Utilize lazy loading for images.&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;experimental: { optimizeCss: true }&lt;/code&gt; in next config to generate critical css (experimental feature).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  First Input Delay (FID)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F57qm65x921xxrd3y1oe9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F57qm65x921xxrd3y1oe9.png" alt="First Input Delay (FID)" width="800" height="465"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;FID quantifies the responsiveness of a web page by measuring the time it takes for a user to interact with it. An ideal FID is less than 100 milliseconds. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq1dmbeo457l13qj14luq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq1dmbeo457l13qj14luq.png" alt="Major Causes of Poor FID" width="800" height="476"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How we can improve FID in Nextjs&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make use of &lt;code&gt;@next/bundle-analyzer&lt;/code&gt; to analyse bundle sizes.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;next/dynamic&lt;/code&gt; tag to implement lazy loading imports of React components where necessary.&lt;/li&gt;
&lt;li&gt;Utilize &lt;code&gt;next/script&lt;/code&gt; tag to optimally load third-party scripts&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Cumulative Layout Shift (CLS)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftg41uymz9nzxzrbpxtle.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftg41uymz9nzxzrbpxtle.png" alt="Cumulative Layout Shift (CLS)" width="800" height="472"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;CLS assesses the visual stability of a page by measuring unexpected layout shifts during its lifespan. A good CLS score is less than 0.1. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjmzw2ridi3hmtb7t5u2i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjmzw2ridi3hmtb7t5u2i.png" alt="Major Causes of Poor CLS" width="800" height="460"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How we can improve CLS in Nextjs&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Take advantage of &lt;code&gt;next/font&lt;/code&gt; to automatically optimize your fonts (including custom fonts) and remove external network requests for improved privacy and performance.&lt;/li&gt;
&lt;li&gt;Add fixed dimensions to &lt;code&gt;next/image&lt;/code&gt; tag images.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Conclusion:
&lt;/h1&gt;

&lt;p&gt;By prioritizing Google Core Web Vitals, you can significantly enhance the user experience of your Next.js project. Optimizing for LCP, FID, and CLS ensures that your website is not only search engine-friendly but also provides a seamless experience for your users. Incorporate these simple strategies into your development workflow to create faster, more responsive, and visually stable web applications.&lt;/p&gt;

&lt;h6&gt;
  
  
  Resources
&lt;/h6&gt;

&lt;p&gt;*&lt;a href="https://www.youtube.com/watch?v=AQqFZ5t8uNc&amp;amp;t=137s"&gt;https://www.youtube.com/watch?v=AQqFZ5t8uNc&amp;amp;t=137s&lt;/a&gt;&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
