Reroute image to webp when supported

Our image backends support on the fly conversion of images based on the extension. We switch from .jpg to .webp in the worker when the browser supports it greatly reducing image size for supported browsers.

https://github.com/vidaxl-com/Cloudflare_webworkers/blob/master/examples/webp.js

4 Likes

HI, Just a curious question. Thanks for the code.

What if we already have the WebP version of the image file on our server. Then we don’t need to convert the file at all no?

Can you help me with the code of it.

Thanks in advance. :slight_smile:

Isn’t polish already served webp version in supported browsers?

Yeah, it does. Polish removes the metadata of the image etc.

As I’m using the compressions services on my WordPress blog, and WordPress already has webP version of the images. If that is possible to do with the workers, just switch the image from JPG or PNG to webP via workers. That will be super fast.