Media Technology Guides

How to Optimize Images for Websites and Core Web Vitals (LCP & CLS)

Core Web Vitals LCP and CLS image optimization checklist

Unoptimized hero images are the #1 bottleneck behind slow Largest Contentful Paint (LCP) and jumping page layouts (CLS). On static sites hosted on Cloudflare Pages or GitHub Pages, disciplined asset optimization makes pages feel instantaneous.

1. Always Set Explicit width and height Attributes

When you include width="800" height="420" directly in HTML alongside CSS img { max-width: 100%; height: auto; }, browsers reserve the exact aspect-ratio box before a single image byte arrives—dropping Cumulative Layout Shift (CLS) to zero.

2. Lazy-Load Below-the-Fold Media (Never the Hero LCP Image!)

Add loading="lazy" to gallery cards, footer thumbnails, and blog post illustrations down the page. However, keep loading="lazy" OFF your primary above-the-fold hero banner so the browser fetches it immediately.

3. Prefer Inline or External SVG for Diagrams and Icons

  1. Export vector illustrations, logos, and UI icons as clean SVGs rather than 300 KB PNGs.
  2. Convert photographic assets to WebP under ~120 KB for full-width banners and ~40 KB for cards.
  3. Describe every meaningful image accurately in its alt attribute for accessibility and Google Images indexing.

Helpful Creator Tips

  • Audit total transferred KB in Chrome DevTools Network tab throttled to Slow 4G—your homepage assets should ideally stay well under 500 KB.
  • Combine static Cloudflare Edge caching with clean filenames.
Prep Web-Ready WebP Assets Resize and compress blog hero and card images offline before deploying.
Compress Web Images →

Frequently Asked Questions

Related Guides