Troubleshooting WebP Image Delivery with EWWW Image Optimizer and Cloudflare
Content
Getting WebP images to display correctly on your WordPress site can be a challenge, especially when using a Content Delivery Network (CDN) like Cloudflare. A common issue reported by users is that while EWWW Image Optimizer successfully generates WebP files, they are not being served to visitors. This guide will explain why this happens and walk you through the most effective solutions.
Why WebP Images Might Not Show with Cloudflare
Cloudflare and other CDNs act as a proxy between your visitor and your server. They often have their own image processing and caching layers that can interfere with the standard methods of delivering WebP images. The default WebP delivery method in EWWW Image Optimizer, which uses Apache or Nginx rewrite rules, is often bypassed by Cloudflare. This means the rewrite rules on your origin server never get a chance to run, so visitors receive the original JPEG or PNG files instead of the optimized WebP versions.
Recommended Solution: Use an HTML-Based Delivery Method
The most reliable way to ensure WebP delivery through Cloudflare is to use an HTML-based method. EWWW Image Optimizer provides two primary options, which can be found under Settings → EWWW Image Optimizer → WebP.
- JS WebP Rewriting: This method uses a small amount of JavaScript to detect WebP support in the user's browser and then rewrite image URLs on the page. It is highly compatible with various hosting setups and CDNs, including Cloudflare.
- <picture> WebP Rewriting: This method rewrites your site's HTML to use the modern
<picture>element, which allows for specifying multiple image formats (e.g., WebP and a fallback).
For most users, enabling both JS WebP and <picture> WebP Rewriting is the recommended configuration. The <picture> method is efficient for most standard images, while the JS WebP method acts as a catch-all for more complex scenarios, such as some lazy-loaded images or background images defined in inline styles.
Step-by-Step Configuration
- Navigate to your WordPress dashboard and go to Settings → EWWW Image Optimizer.
- Click on the WebP tab.
- Ensure the JPG/PNG to WebP conversion option is enabled.
- Check the boxes for both JS WebP Rewriting and Picture WebP Rewriting.
- Scroll down and click Save Changes.
Important Considerations and Limitations
- Cloudflare Polish: An alternative to HTML rewriting is to use Cloudflare's own Polish feature, which can automatically serve WebP images. However, this is a separate service from Cloudflare and is not directly related to the WebP files generated by EWWW Image Optimizer on your server.
- Background Images: A significant limitation of JS WebP rewriting is that it cannot modify background images that are defined in external CSS files or within
<style>tags in the page header. This is a common reason why background images from page builders like Elementor may not convert to WebP. The EWWW Image Optimizer team has addressed this specific limitation in their Easy IO CDN service, but for the standalone plugin, these images often cannot be altered. - Cache: After changing any WebP or Cloudflare settings, you must purge all relevant caches. This includes your WordPress cache plugin (e.g., W3 Total Cache, WP Rocket) and your Cloudflare cache via the Cloudflare dashboard.
How to Verify WebP is Working
To confirm that your images are being served as WebP, open your website in Google Chrome and use the Developer Tools:
- Right-click on your page and select Inspect.
- Go to the Network tab.
- Reload the page.
- In the network log, look at the list of loaded files. Click on an image file and look at the Headers tab. The Content-Type header should say
image/webpfor images that are being delivered as WebP.
By following this guide and understanding the interaction between EWWW Image Optimizer and Cloudflare, you should be able to successfully configure your site to deliver faster-loading WebP images to your visitors.
Related Support Threads Support
-
What does the option “Plaid” do?https://wordpress.org/support/topic/what-does-the-option-plaid-do/
-
CSS Backgrounds and webphttps://wordpress.org/support/topic/css-backgrounds-and-webp/
-
webP not generated for Elementor Background Sliderhttps://wordpress.org/support/topic/webp-not-generated-for-elementor-background-slider/
-
Using webp with Cloudflarehttps://wordpress.org/support/topic/using-webp-with-cloudflare/
-
After turning on cloudflare, webp is not loaded anymorehttps://wordpress.org/support/topic/after-turning-on-cloudflare-webp-is-not-loaded-anymore/
-
WebP Delivery Method Cloudways sites should use JS WebPhttps://wordpress.org/support/topic/webp-delivery-method-cloudways-sites-should-use-js-webp/
-
Which Option to select? (I am using cloudflare)https://wordpress.org/support/topic/which-option-to-select-i-am-using-cloudflare/
-
WebP Delivery Method?https://wordpress.org/support/topic/webp-delivery-method/
-
Background images – WebPhttps://wordpress.org/support/topic/background-images-webp/
-
Cloudflare and WebP?https://wordpress.org/support/topic/cloudflare-and-webp/
-
Exclude images from webp, but not from optimization?https://wordpress.org/support/topic/exclude-images-from-webp-but-not-from-optimization/
-
Cloudflare Setuphttps://wordpress.org/support/topic/cloudflare-setup-2/