If you use the <picture> element [0], then you can specify a MIME type on the srcset. Browsers will then use this to load an image they support - so if you have a set of pictures with a MIME type of image/webp and others with image/jpeg, WebP will be used by those browsers that support it and JPEG by those that don't. There's a good example at [1].
Alas although most browsers support the picture element, IE11 is the notable exception [2] and a polyfill is required.
Alas although most browsers support the picture element, IE11 is the notable exception [2] and a polyfill is required.
[0] https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pi...
[1] https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimed...
[2] https://caniuse.com/#feat=picture