How to serve WebP images in WordPress

On this page
  1. 1. Using a WordPress plugin
  2. 2. Using server-side configuration
  3. 3. Using JavaScript detection
  4. Browser compatibility
  5. Practical considerations
  6. Summary

WebP is a modern image format that provides better compression and smaller file sizes compared to traditional formats like JPEG and PNG. Serving WebP images on a WordPress website can improve performance and loading speed.

There are several ways to enable WebP support in WordPress depending on your setup and server configuration.

1. Using a WordPress plugin

The simplest method is to use a plugin that automatically converts and serves WebP images.

Popular options include:

  • WebP Express
  • EWWW Image Optimizer

These plugins typically:

  • convert uploaded images to WebP format
  • serve WebP versions to compatible browsers
  • keep original images as fallback for older browsers

This method requires minimal technical configuration.

2. Using server-side configuration

If your hosting uses Apache or NGINX, WebP delivery can be configured at the server level.

For Apache, this is usually done via .htaccess rules. For NGINX, configuration is done in the server block settings.

In this setup, the server:

  • detects browser WebP support
  • serves .webp files when available
  • falls back to JPEG or PNG if needed

This method is efficient but requires server access and technical knowledge.

3. Using JavaScript detection

Another approach is to use JavaScript to detect browser support for WebP.

The script:

  • checks whether the browser supports WebP
  • loads WebP images if supported
  • falls back to standard formats if not supported

This method can be added via:

  • theme files (such as functions.php)
  • header scripts (header.php)

However, it is less efficient than server-side solutions.

Browser compatibility

Most modern browsers support WebP, but older browsers may not.

For this reason, it is important to:

  • keep original JPEG or PNG files as fallback
  • ensure proper conditional delivery of images

Practical considerations

When implementing WebP in WordPress, consider:

  • plugin-based solutions are easiest for beginners
  • server-level configuration offers better performance
  • backups of original images should always be preserved
  • testing is important to ensure compatibility

Summary

WebP images can be served in WordPress using plugins, server configuration, or JavaScript-based detection. Plugins are the simplest option, while server-level solutions provide the best performance. In all cases, fallback support for older browsers should be maintained.

Didn't find an answer?

Our support team is here for you 24/7 – write to us and we will help you sort it out.