How do I optimise images?
Last checked 31 Aug 2026
Short answer
Resize images to their actual display size, compress them, convert to WebP/AVIF where practical, and lazy-load anything below the fold — ask Lovable to apply this across the project, not just one page.
The core steps
- Resize to display size. An image shown at 600px wide doesn't need to be 3000px wide — resize before or during upload.
- Compress. Even at the correct dimensions, unoptimised JPEG/PNG files are often 2-5x larger than they need to be.
- Use modern formats. WebP (or AVIF) gives similar quality at a smaller file size than JPEG/PNG for most photographic and graphic content.
- Lazy-load below-the-fold images. Anything not visible on initial load shouldn't compete for bandwidth with what is.
- Don't lazy-load the hero/LCP image — that one should load eagerly since it's what Core Web Vitals measures first.
How to ask Lovable
Review all images used in this project. Resize and compress any that are larger than their display size, convert suitable ones to WebP, and lazy-load images that appear below the fold. Leave the hero image loading eagerly.
Ongoing habit, not one-off
Every time you add a new image (product photo, blog header, team photo), apply the same rules — compression tends to be forgotten for anything added after the initial build.
What usually goes wrong
- Converting every image to WebP without checking older browsers/exports still need it in a fallback format for edge cases (rare, but worth a quick check if you support very old browsers).
- Compressing so aggressively that quality visibly degrades — aim for the smallest file size that still looks sharp, not the smallest possible file.
- Forgetting images used as CSS backgrounds — these are often missed in a component-by-component review.
See /questions/how-do-i-lazy-load-images and /questions/how-do-i-improve-lcp for related fixes.
Sources
Was this answer helpful?
Related questions
- AnswerWhy is my database making so many requests?Usually a component is re-fetching data on every render, a page is running the same query multiple times, or you're fetching entire tables instead of what's actually needed — ask Lovable to audit data-fetching patterns.
- AnswerHow do I improve Core Web Vitals?Focus on the three metrics Google measures — LCP (loading), INP (interactivity), and CLS (visual stability) — and fix the specific one flagged as poor, usually starting with images for LCP.
- AnswerHow do I lazy-load images?Ask Lovable to add native lazy-loading to images below the fold while keeping the hero/first-visible image loading eagerly, so visitors aren't downloading offscreen images before they're needed.
- AnswerHow do I remove unused code?Ask Lovable to search for unused components, imports and dependencies, or run a tool like ts-prune/depcheck via the terminal, then remove what's confirmed unused and re-test.