You should use the HTML picture element as described in w3schools :
<picture> <source type="image/webp" srcset="img_pink_flowers.webp"> <source srcset="img_white_flower.jpg"> <img src="img_orange_flowers.jpg" alt="Flowers" style="width:auto;"> </picture>
The latest img ad is a fallback for incompatible browsers. The order of the sources determines the importance of each format. So, if the first one is available in its browser, the first one will load.
source share