Image and Static Resource Optimization: What to Do First and Last

Should you compress quality first or resize first? A wrong order cuts your gains in half. The correct order is **reduce unnecessary bytes first, then improve en…

Insights:Image and Static Resource Optimization: What to Do First and Last

Step 1: Measure — Identify the Largest Ones

  • Capture all images on the page and sort by file size.
  • Record total size and the maximum single-image size.
  • Log the first-screen load time as a baseline.

Rule of thumb: typically 20% of images account for 80% of the total size, so tackle those first.

Step 2: Resize (Highest Impact)

  • Determine the display width for each image.
  • Generate images at that display width, plus an extra 2× variant.
  • Do not reuse detail-page large images for list thumbnails.

Verification: Single-image file size drops and total page byte count decreases.

This step requires no format change — simply resizing eliminates most waste.

Step 3: Switch Format

Content Type Recommended Format Note
Photos & scenes WebP (preferred), AVIF (optional) Fallback needed for compatibility
Icons & logos SVG Vector format, extremely small
Transparency + complex colors PNG Do not use PNG for photos
Screenshots WebP or PNG Depends on color complexity

Keep original files when converting, for easier future adjustments.

Step 4: Adjust Quality

  • Photo quality at 75–85 is imperceptible to the naked eye.
  • Compare each image individually; do not squash everything to the lowest setting.
  • Larger images can be compressed more; smaller ones may not need compression at all.

Step 5: Add Lazy Loading & Explicit Dimensions

  • Add loading="lazy" to images below the fold.
  • Declare width and height for all images to prevent layout shifts.
  • The hero image can use fetchpriority="high" to boost its priority.

Step Six: Configure Caching and Versioning

  • Cache static assets for a long duration.
  • Hash filenames so any update gets a new name.
  • Update CDN rules in sync.

Verification Checklist

  • Percentage reduction in total page byte size.
  • Change in first-screen load time.
  • All images display correctly with no 404 errors.
  • No noticeable blurring or distortion on mobile.

Common Mistake Sequences

  • Convert the entire site to AVIF first, then realize dimensions were never changed — limited gains.
  • Only compress quality while images remain at 2000px wide.
  • Add lazy loading to the first screen, making it slower.
  • Switch format but keep the same filename; users see the stale cached image.

Limits

Image optimization improves load-time and experience metrics, but cannot compensate for a slow backend. If TTFB exceeds 1 second, investigate server-side performance and caching strategy first.

Related Reading: