Performance Hands-On 1 - Largest Contentful Paint (LCP)

hero-image

📋 Instructions

In this hands-on exercise, you will learn how to measure and optimize the Largest Contentful Paint (LCP) metric using browser DevTools.

🔍 Measuring LCP

  1. 🛠️ Open the browser DevTools by pressing F12 or Ctrl+Shift+I (Windows/Linux) or Cmd+Opt+I (Mac).
  2. 📊 Navigate to the "Performance" tab.
  3. 🔄 Click the "Reload" button (circular arrow) to start recording and reload the page.
  4. ⏱️ After the page loads, the recording will stop automatically.
  5. 🔍 Look for the "LCP" marker in the "Timings" section of the recording.
  6. 👆 Click on the LCP marker to see details about the LCP element in the summary panel below.
  7. 🐢 Note: You can use CPU throttling to simulate slower CPU if needed.
  8. 🔎 Check the console for LCP measurements, there is another way to identify the LCP element on this page. Observe its code.
  9. ⚡ Click the "Optimize LCP" button below to apply optimizations. Observe the changes in the image tag.
  10. 💾 To save the optimized version use the "Overrides" feature in DevTools:
    1. 📂 In DevTools, go to the "Sources" tab
    2. 🖱️ Right-click in the navigator panel on the index.html file and select "Override content"
    3. 📁 Select a folder and grant permission
    4. ✏️ Open the optimized index.html file in the editor panel and add the optimized content.
    5. 📋 Right-click on image element in the elements tool and copy the optimized element
    6. 🔄 Refresh the page to see the changes.
  11. 📈 Record the LCP time again and compare the improvement.

🛠️ Common LCP Optimization Techniques

📚 Additional Resources