MODX WebP Auto-Converter is a universal image optimization plugin designed to automatically convert PNG/JPEG to WebP during page rendering.
Built for MODX but works with any PHP-based project with minimal tweaks.
✅ Works even on shared hosting
✅ No external APIs or paid services
✅ Google PageSpeed friendly
✅ Fully automated once installed
Without WebP automation, websites suffer from:
| ❌ Problem | 💥 Impact |
|---|---|
| Large PNG/JPEG files | Slow page load, higher bounce rate |
| Poor Google PageSpeed score | Lower SEO rankings |
| Manual image conversion | Time-consuming and error-prone |
| Shared hosting restrictions | Cannot install heavy packages |
| Serving old formats to modern browsers | Missed performance gains |
| ✅ Feature | 🚀 Benefit |
|---|---|
Scans HTML <img>, srcset, data-src and CSS url(...) |
Finds all images automatically |
| Generates WebP on the fly | No need for manual conversion |
| Uses GD or Imagick (if available) | Works on any hosting setup |
| Serves WebP only to supported browsers | 100% compatibility |
| Caches replacements | Minimal server load |
Supports OnSiteRefresh |
Clears all WebP cache in one click |
- In MODX: Go to Elements → Plugins → Create.
- Name it WebP Auto-Converter.
- Paste the code from this repository.
- Enable events:
OnManagerPageBeforeRenderOnWebPagePrerenderOnSiteRefresh
- Save → Clear MODX cache → Done! 🎉
After installing:
- 🚀 20–60% faster page loads
- 📊 +10–20 points in Google PageSpeed
- 🕒 Zero time spent on manual conversions
- 🌍 Works with any site — blog, e-commerce, portfolio
- 🔄 Fully automated & future-proof
| Component | Details |
|---|---|
| Language | PHP 7.0+ |
| Libraries | GD, Imagick |
| Server | Apache / Nginx |
| CMS | MODX Revolution (tested), adaptable to others |
| Caching | Built-in PHP caching |
| Browser Support | Chrome, Firefox, Edge, Opera, Safari (partial WebP) |
MIT — free to use and modify.