The speed of a website is one of the biggest factors in how high your bounce rate is going to be. Image files are mostly the reason for slow loading pages. Plus, Google negatively scores websites with slow loading pages. WebP is an image format that lets you decrease the size of your images by up to 35% and load the pages quicker.
Table of Contents
What is WebP?
WebP is a modern web image format developed by Google that lets you shrink your image size without affecting how it looks. The reduction in size is going to depend on the type of compression chosen during conversion i.e., lossy or lossless.
Uploading WebP images to WordPress
By default WordPress does not support the WebP format. Whenever you will try to upload a WebP image file it will give an error message saying “Sorry, this file type is not permitted for security reasons”.
Below are steps to upload WebP image files to WordPress
- Visit Appearance -> Theme Editor from your admin dashboard.
- Select the functions.php file under Theme Files.
- Paste the below code in the editor at the bottom and save the changes.
// Add support for WebP image format function webp_upload_mimes( $current_mimes ) { $current_mimes['webp'] = 'image/webp'; return $current_mimes; } add_filter( 'mime_types', 'webp_upload_mimes' ); // Display WebP images in Media Library function display_WebP($result, $path) { if ($result === false) { $displayable_image_types = array( IMAGETYPE_WEBP ); $info = @getimagesize( $path ); if (empty($info)) { $result = false; } elseif (!in_array($info[2], $displayable_image_types)) { $result = false; } else { $result = true; } } return $result; } add_filter('file_is_displayable_image', 'display_WebP', 10, 2);
- Once done you will now be able to upload the WebP image files in your WordPress website and preview them in the Media Library.
Conclusion
Using WebP image format instead of JPEG or PNG formats can be beneficial in many ways. WebP format will help in reducing the image size which will increase the page load speeds and in turn reduce the bounce rate. This will also be beneficial in improving the SEO score of the website.
The only con of using WebP format for images on your website is that since it is a new image format not all the browsers support it. Most notably the Safari browser still does not supports it which has almost a share of 20% mobile browser users.