Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/DevOps & cloud

Web Performance Optimization: Core Web Vitals Guide

Optimize for Core Web Vitals — LCP, INP, CLS — with practical techniques for images, fonts, JavaScript, and server response times.

22 February 20261 min readDevOps & cloudاقرأ بالعربية

On this page

  1. The Three Core Web Vitals
  2. Image Optimization
  3. Font Optimization
  4. JavaScript Optimization
  5. Server-Side Optimizations

Google uses Core Web Vitals as a ranking factor. Sites with good CWV scores see 24% fewer user abandonments (Google Chrome UX Report, 2024).

The Three Core Web Vitals

LCP (Largest Contentful Paint) — Loading
  Good: ≤ 2.5s | Poor: > 4.0s

INP (Interaction to Next Paint) — Interactivity
  Good: ≤ 200ms | Poor: > 500ms

CLS (Cumulative Layout Shift) — Visual Stability
  Good: ≤ 0.1 | Poor: > 0.25

Image Optimization

html
<picture>
    <source srcset="hero.avif" type="image/avif">
    <source srcset="hero.webp" type="image/webp">
    <img src="hero.jpg" alt="Hero" width="1200" height="600"
         loading="lazy" decoding="async">
</picture>

<!-- LCP image: preload and eager load -->
<link rel="preload" as="image" href="hero.avif" type="image/avif">
<img src="hero.avif" fetchpriority="high" alt="Hero">

Font Optimization

html
<link rel="preload" href="/fonts/inter.woff2" as="font"
      type="font/woff2" crossorigin>
<style>
@font-face {
    font-family: 'Inter';
    src: url('/fonts/inter.woff2') format('woff2');
    font-display: swap;
}
</style>

JavaScript Optimization

html
<script src="app.js" defer></script>
<script src="analytics.js" async></script>
javascript
const Dashboard = () => import('./pages/Dashboard.vue');

requestIdleCallback(() => {
    loadAnalytics();
    prefetchNextPage();
});

Server-Side Optimizations

php
Route::middleware('cache.headers:public;max_age=3600;etag')
    ->get('/api/posts', [PostController::class, 'index']);
ini
opcache.enable=1
opcache.memory_consumption=256
opcache.jit=1255
opcache.jit_buffer_size=100M

Use Lighthouse and PageSpeed Insights to measure. Aim for a Lighthouse score above 90.

All articles

Keep reading

  • Docker for Developers: From Zero to Containerized Applications28 February 20261 min read
  • CI/CD Pipelines with GitHub Actions: Automate Everything22 February 20261 min read
  • Clean Code Principles: Write Code That Humans Can Read22 February 20261 min read