Prompt to optimize images in an exported site
This prompt asks an AI assistant to find the heavy images in an exported site, convert them to WebP, set width and height on each tag, add lazy loading to images below the fold, and leave the main above-the-fold image eager, since web.dev advises against lazy-loading the largest contentful image. It keeps the originals.
Last reviewed
Key facts
- web.dev recommends modern image formats such as AVIF or WebP and image compression.
- web.dev says never to lazy-load the Largest Contentful Paint image.
- The WebExport Free plan limits an export to 20 MB, and images are usually the biggest part.
- Test status: run on a real export. Every image was under the 200 KB threshold, so nothing needed converting, and the measurement commands worked.
The prompt
Paste this into Claude Code, Cursor, Gemini CLI or another AI coding assistant with your project folder open, and replace everything in square brackets first. See how to run it in each tool.
You are reducing image weight in a static site in [PROJECT_FOLDER] without changing how pages look.
STEP 1: MEASURE
List every image over [SIZE: 200 KB] with path, size, pixel dimensions and the pages that use it. Write the table to IMAGES.md, largest first.
STEP 2: CONVERT
- Create WebP versions of JPEG and PNG images using [TOOL: cwebp, sharp or squoosh-cli]. Use a quality that is hard to tell from the original at normal viewing size.
- Do not upscale. If an image is much wider than the largest size it is shown at, resize it to about twice that width at most.
- Keep the original files in an originals folder. Do not delete them.
STEP 3: UPDATE THE MARKUP
- Point each img at the WebP file. Use a picture element with the original as the fallback only if I ask.
- Add width and height attributes that match the file, so the page does not jump while loading.
- Add loading="lazy" to images that are below the first screen.
- Find the largest image in the first screen of each page. Leave it without loading="lazy". Add fetchpriority="high" to it.
STEP 4: REPORT
Write IMAGES_REPORT.md with total size before and after, and every image you skipped and why.
RULES
- Never change an image's crop or aspect ratio.
- Ask before you touch logos and SVG files.How to run it
- Work on a copy and keep the originals, so you can compare quality.
- Send the prompt, read IMAGES.md first, and agree on the size threshold.
- Check three pages at phone and desktop width for blurry or stretched images.
- Build, deploy a preview and run a speed test before and after to confirm the change.
Which attribute goes where
| Image position | loading | fetchpriority | Why |
|---|---|---|---|
| Largest image in the first screen | Leave as eager | high | web.dev advises against lazy-loading the LCP image and recommends a high priority hint |
| Other images in the first screen | Leave as eager | Not needed | Visitors see them at once |
| Images below the first screen | lazy | Not needed | They load as the visitor scrolls |
Verify the result
Compare the folder size before and after, and list any large image that survived. The Static Site Image Optimizer converts images to WebP in the browser if you prefer to do it by hand.
du -sh exported-site
find exported-site -type f \( -name "*.jpg" -o -name "*.jpeg" -o -name "*.png" \) -size +200k | head -20
grep -rn "<img" exported-site --include="*.html" | grep -v "width=" | head- The folder is smaller and no page looks worse at phone or desktop width.
- Large JPEG and PNG files remain only where the report says you skipped them.
- Every img has width and height, and the main first-screen image is not lazy-loaded.
What can go wrong
- Lazy-loading the main image slows the first view. The prompt protects it, but check the result.
- Heavy compression that shows as banding in gradients. Compare the originals side by side.
- Setting width and height that do not match the file distorts the image. Check the ratios.
Frequently asked questions
Is WebP safe to use?
WebP is a widely supported format, and web.dev recommends modern formats such as AVIF or WebP. Keep the originals so you can change your mind.
Why keep the main image eager?
web.dev says never to lazy-load the Largest Contentful Paint image, because it delays the main visual of the page.
Will this fix a Free plan size limit?
It helps with hosting size after the export. The Free plan limit of 20 MB applies to the export itself, which Professional raises to 2 GB.
Which tools show where the weight is?
The Website Asset Size Analyzer reports image, JavaScript and CSS weights and points at the biggest files.
Official documentation
Free tools for this job
- Static Site Image OptimizerConvert images to WebP to eliminate hosting bandwidth overages.
- Website Asset Size AnalyzerAnalyze all images, JS, and CSS weights to find performance bottlenecks.
- Static Site Hosting Cost CalculatorCompare hosting costs: Webflow vs Vercel vs Netlify vs Cloudflare Pages at scale.
- Framer Site Speed TesterRun performance checks on any Framer-published URL with actionable insights.
Start with the files
Prompts work best on a WebExport download of your site. Paste your public URL into the export form and get a ZIP. The Free plan covers 1 site, 5 exports a month, 15 pages and 20 MB per export. Professional is a $9.99 one-time purchase with unlimited pages.