I'm building a simple WordPress theme for personal use. Speed is important. My Google PageSpeed Score is high, but it keeps saying that I should use WebP, rather than JPG. ('modern web formats').
As I've built my theme completely from scratch, so that it only contains the bare necessities and no other unneeded things.
I would very much like not to use a plugin for this, but do it myself. So I came up with the following:
- Upload JPG/PNG
- WordPress creates all the image sizes twice: once in JPG/PNG (the original format) and once in WebP
- When the page is loaded, I check whether to call the WebP version (when the browser supports it) or the original.
I already Googled a lot about webp in WordPress, but I only found out about plugins. I found this unanswered question with sample code for converting JPG/PNG to WebP, but I don't know if this is really correct. To me it seems like only the extension is changed. Does anybody know if that's also correct?
How do I add image sizes and convert an additional set to WebP?
Many thanks in advance!