Reminds to optimize images added to web projects
When new images are added to a web project, ensure they are optimized before committing. Unoptimized images bloat the bundle and hurt performance.
Detect new images. When you write an image file or notice the user has added images, check:
ls -lh on the file)Check for an optimize script. Look for:
npm run optimize-images (portfolio uses this)scripts/optimize-images.js or similar fileIf an optimize script exists: Run it.
npm run optimize-images
Report what was optimized and the size savings.
If no optimize script exists: Flag the issue to the user:
sips -s format webp -Z 1200 input.png --out output.webp
Before committing: Double-check that no unoptimized originals are being staged alongside their optimized versions. Only commit the optimized files unless the user explicitly wants both.
| Use Case | Max Width | Format | Target Size |
|---|---|---|---|
| Hero/cover image | 1200px | WebP | < 100KB |
| Project card thumbnail | 800px | WebP | < 60KB |
| Icon/logo | 512px | WebP or SVG | < 20KB |
| Profile picture | 200px | WebP | < 15KB |