<?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>Forem: Ashish Kumar</title>
    <description>The latest articles on Forem by Ashish Kumar (@ashishyadavcs).</description>
    <link>https://forem.com/ashishyadavcs</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%2F888565%2F2c77eed7-c694-4748-893d-bf2dc48f0f1b.jpg</url>
      <title>Forem: Ashish Kumar</title>
      <link>https://forem.com/ashishyadavcs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ashishyadavcs"/>
    <language>en</language>
    <item>
      <title>How to fix/improve the LCP issue on the webpage?</title>
      <dc:creator>Ashish Kumar</dc:creator>
      <pubDate>Wed, 04 Dec 2024 04:35:36 +0000</pubDate>
      <link>https://forem.com/ashishyadavcs/who-to-fix-the-lcp-issue-on-webpage-4lgn</link>
      <guid>https://forem.com/ashishyadavcs/who-to-fix-the-lcp-issue-on-webpage-4lgn</guid>
      <description>&lt;p&gt;LCP is one of the main factors affecting the performance of web pages.LCP is the time taken to paint the largest web page element on the pixel of the screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flgtxfxvyhh3q5ar2kevu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flgtxfxvyhh3q5ar2kevu.png" alt="how to fix lcp of webpage" width="768" height="192"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Factors affecting LCP
&lt;/h2&gt;

&lt;p&gt;There are following factors that cause LCP increase in webpage&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Large image size in the first viewport&lt;/li&gt;
&lt;li&gt;Heavy animation, background image in the banner/ first section&lt;/li&gt;
&lt;li&gt;images are not lazy-loaded&lt;/li&gt;
&lt;li&gt;unused script and CSS&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How to fix this
&lt;/h2&gt;

&lt;p&gt;to fix LCP you need to improve above mentioned factors&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Optimize image size and use the latest image formats like webp &amp;amp; avif&lt;/li&gt;
&lt;li&gt;use async and defer to avoid render blocking
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script defer src="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script async src="./main.js"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Lazy-load images other than the first section
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;img loading="lazy" class="shape" src="./images/coffee-shape.svg" /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or use intersection observer for lazy loading &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Optimize unused CSS by using the media attribute
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;link
    media="print"
    onload="this.media='all'"
    rel="stylesheet"
    href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css"
/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Preload banner image or background image
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;link rel="prelod" as="image" href="./images/banner-bg.png"/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Other than these fixes you will have to follow suggestions which lighthouse is suggesting you to fix.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9hl27k3cuki20kcmbycu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9hl27k3cuki20kcmbycu.png" alt="Image description" width="800" height="190"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Result : &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6eip3c664pddp4lnvnzz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6eip3c664pddp4lnvnzz.png" alt="Image description" width="800" height="324"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;follow me &lt;br&gt;
website : &lt;a href="https://www.frontendzone.com/blog/improve-lcp-on-mobile-100-working-method" rel="noopener noreferrer"&gt;frontendzone&lt;/a&gt;&lt;br&gt;
Youtube : &lt;a href="https://www.youtube.com/watch?v=rrRspZv9JCw&amp;amp;t=1107s" rel="noopener noreferrer"&gt;frontendzone&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to update object key in useState</title>
      <dc:creator>Ashish Kumar</dc:creator>
      <pubDate>Tue, 07 Feb 2023 16:09:00 +0000</pubDate>
      <link>https://forem.com/ashishyadavcs/how-to-update-object-key-in-usestate-33h6</link>
      <guid>https://forem.com/ashishyadavcs/how-to-update-object-key-in-usestate-33h6</guid>
      <description>&lt;p&gt;To update an object key in the state select the key and assign its value to that state&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    onClick={(e) =&amp;gt;
            setBooks((prev) =&amp;gt; ({
              ...prev,
              physics: e.target.value,
            }))
          }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://frontendzone.com/blog/how-to-set-object-key-in-usestate-react-state-hook-with-the-object-and-array" rel="noopener noreferrer"&gt;read more&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>promptengineering</category>
      <category>tools</category>
      <category>openai</category>
    </item>
  </channel>
</rss>
