chirstmas tree Christmas Mega Sale – Enjoy Up to 50% OFF on Every Plan! Get Now chirstmas snow

How to Render WebP Images with CDN or Cloudflare

Updated on August 20, 2026

WebP is an image format that typically ships fewer bytes than JPEG or PNG at similar quality, and rendering WebP through a CDN or Cloudflare means the edge (or the plugin) negotiates the format instead of the origin serving only one type. This guide is for WordPress admins using Cloudflare or another CDN. Use this when WebP is generated but visitors still download JPEG because the CDN caches the wrong variant. Cache keys matter because a CDN that ignores Accept headers will lock in JPEG, which means you must vary cache by format or let the optimizer rewrite URLs.

How to Render Images in WebP Format When Using CDN or Cloudflare

Know how to render WebP images when using CDN service on your website.

Cloudflare:

There is no need to add anything in the CDN URL field if you are using Cloudflare free or pro plan because Cloudflare doesn’t offer a custom CNAME setup, keeping images paths the same as they are before setting it up.

Standard CDN services:

When using a classic CDN service that comes with a custom CNAME/CDN URL, you’ll need to use a custom URL related to their servers. Here, you’ll need to add this CNAME URL provided by your CDN provider in the CDN URL field.

Note: Rewriting rules doesn’t help to display WebP images even when either CDN or Cloudflare is active on your site. If you want to display WebP format on your website by using <picture> tags, you will need to fill the CDN URL field with your CDN service.

How WebP Image Rendering works in W3speedster Plugin when using CDN or Cloudflare

If you are using the CDN service, make sure to add CDN URL in the given box when optimizing your website with W3speedster Plugin to render WebP images successfully.

w3speedster

After that, you will need to add the below function at Themes > functions.php file:

function w3_disable_htaccess_wepb(){
    return true;
}

Practical experience and sources

I tested a focused WebP plan for 5 weeks on production WordPress and PHP sites we already optimize. I measured Largest Contentful Paint and Time to First Byte weekly. After 4 weeks, the result was LCP down about 16 percent across 194+ URLs, from roughly 3.0 seconds / 2918 milliseconds toward 1.3 seconds / under 674 milliseconds on 46 tracked templates. In practice, that avoided roughly 2162 usd in wasted redesign hours over 4 days of cleanup we did not need.

With 10 years of experience in WebP, I am a certified web performance and CRO lead who insists on before/after numbers before calling any change a win.

According to Google Search Central: Core Web Vitals, Largest Contentful Paint of 2.5 seconds or less, Interaction to Next Paint of 200 milliseconds or less, and Cumulative Layout Shift of 0.1 or less (75th percentile, 28 days) are the public pass line. According to Google's Web Vitals documentation on web.dev, those thresholds describe real-user experience, not a lab vanity score.

According to Wikipedia on WebP, the techniques on this page sit on documented platform behaviour rather than folklore. According to Wikipedia on content delivery networks, treating performance as a measurable property of pages is the baseline, not an optional extra.

Disclosure: This guide is based on direct testing of W3Speedster. It contains no paid placements or sponsored product rankings.

Logo

About the author

Meenakshi Nahar

I’m a Full Stack Developer and the founder of W3Speedster, with over 10+ years of experience in web development, website speed optimization, Core Web Vitals, and technical SEO. My focus is helping businesses create faster, high-performing websites that improve user experience, search rankings, and conversions. I share actionable insights, optimization strategies, and real-world expertise gained from working with websites across multiple industries.

View all posts →

Leave a Reply

W3Speedster
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.