WebP-Images without Plugin

WebP is a modern image format which shines through its fairly small filesize. Google recommends through their PageSpeed Insights that all PNG- and JPEG-files should be served as WebP images instead. There are of course plugins to facilitate the automatic generation of WebP versions of existing images but a few lines of PHP code and a .htaccess rewrite rule is really all that is needed to automatically serve all existing PNG- and JPEG- images as WebP versions to browsers that support it.