Prompt
I'm building a workflow that compresses images during deploy
Latest observation
Nov 2, 2026
OpenAI APIWeb search: off
Nice idea — compressing images at deploy time can be a good way to reduce bundle size and improve load performance.
A few practical notes to make it work well:
- Prefer build-time over deploy-time if possible. Deploy-time compression can slow deployments and make failures harder to recover from.
- Use deterministic compression so the same input always produces the same output.
- Keep originals somewhere safe in case you need to reprocess with different quality settings.
- Cache aggressively so unchanged images aren’t recompressed every deploy.
- Choose format-aware tools:
- JPEG: mozjpeg, jpegoptim
- PNG: optipng, pngquant
- WebP/AVIF: cwebp, avifenc
- Set quality thresholds carefully to avoid visible artifacts.
- Validate dimensions and metadata if you strip EXIF or resize images.
A common pattern is:
- Detect changed images
- Run compression tool(s)
- Output optimized assets to an artifacts folder
- Upload or publish those assets as part of deploy
- Serve them with long cache headers and content hashing
If you want, I can help you design:
- a CI/CD pipeline for this,
- a Node/Python script to compress images,
- or a Docker-based deploy step.