
Using WebP in MODX can significantly improve your site's speed, especially if you're using a lot of images.
WebP images are compressed, which reduces their file size and makes them load faster.
This can lead to a noticeable improvement in page load times, especially for users on slower connections.
In fact, switching to WebP images can reduce page load times by up to 40%.
By making this simple change, you can give your users a better browsing experience and improve your site's overall performance.
For another approach, see: How Do Websockets Improve Real-time Communication in Web Applications
Why Use WebP in MODX
Using WebP in MODX can significantly improve your website's performance. WebP compresses images losslessly 26% better than PNG.
By implementing WebP, you can reduce the time it takes for your website to load. This is especially important for users with slower internet connections. WebP compresses lossy images better than JPEG by 25-34% with the same structural similarity index (SSIM).
One of the key benefits of WebP is its ability to support lossless transparency with a size increase of only 22%. This means you can maintain the quality of your images while reducing their file size.
Here are some key statistics on WebP's performance:
- WebP compresses images losslessly 26% better than PNG.
- WebP compresses lossy images better than JPEG by 25-34% with the same structural similarity index (SSIM).
- WebP supports lossless transparency (known as alpha) with a size increase of only 22%.
By using WebP, you can also improve your website's Core Web Vitals, such as Largest Contentful Paint (LCP), and reduce the load on your server. This can even lead to better search engine rankings, as Google takes website speed into account when ranking websites.
Image Optimization
Image optimization is a special processing of a graphic file to minimize its size without losing visual quality. This can be done by removing unnecessary data, such as metadata, and merging similar colors.
To carry out image optimization, complex algorithms are used, but they're all based on the same principle: removing unnecessary data and merging similar colors. This results in a file that's significantly smaller in size without compromising image quality.
The benefits of image optimization are numerous. For instance, it can reduce the size of an image file by up to 98% without losing quality, making it faster to download online resources.
Here's an interesting read: Css in Html File
Optimizing images can significantly speed up a site's loading time. In fact, compressing images on a site can reduce their volume to 75-98% without losing visual quality.
Google's WebP format offers the best combination of file size and quality. It's developed over a decade ago and has been well-tested on many Google services, making it a highly recommended format by Google PageSpeed Insights.
Here are some key benefits of using WebP images:
- Reduced file size: By up to 34%, WebP images are smaller than their JPEG and PNG counterparts of equal quality.
- Enhanced image quality: WebP utilizes advanced compression techniques that maintain image quality while reducing file size.
- Transparency support: WebP supports both lossy and lossless transparency, making it a versatile option for images with transparent backgrounds.
- Broad browser compatibility: Most modern browsers, including Google Chrome, Firefox, and Microsoft Edge, support WebP.
Converting old PNG/JPEG formats to WebP is easy with various utilities available, but converting all images of an already created site can be a daunting task. Special utilities, such as OptiPic CDN, can be used to compress MODX images by converting PNG/JPEG to WebP.
Consider reading: X Friendly Reminder to save Webp Pictures as Png
Troubleshooting
Troubleshooting is a crucial step in ensuring your webp modx plugin runs smoothly. If you encounter any errors, they will be displayed in the MODX user menu.
The errors you may see include "Could not create MODX class" which indicates the API MODX couldn't be initialized, and "Unauthorized" which means there's an authentication issue with the MODX Manager. If you see "Wrong Bin file!" it means the CWEBP utility file wasn't found.
Explore further: The Html File
Here's a list of common errors and their meanings:
- Could not create MODX class - Не удалось инициализировать API MODX;
- Unauthorized - Ошибка авторизации MODX Manager;
- Wrong Bin file! - Не найден бинарный файл утилиты CWEBP;
- Exec function disabled! - PHP функция EXEC отключена в PHP.INI;
- Bin file for: %PHP_OS% not found in ~Binaries/ - Не найден файл утилиты CWEBP для %операционной системы% сервера;
- Bin file not work! return code: %127% - Бинарный файл утилиты CWEBP вернул ошибку: %код ошибки%.
Problems
MODX Revolution, our beloved CMS, has its own set of problems when it comes to supporting WebP. Even with plugins like thumbOf, which creates cached copies in this format, there are occasional misunderstandings with browsers.
Some of the issues you might encounter with MODX include problems with creating MODX classes and unauthorized errors in the MODX Manager.
The errors that occur while working with the plugin will be displayed in the MODX User Menu. Here's a list of possible errors you might see:
- Could not create MODX class - Не удалось инициализировать API MODX;
- Unauthorized - Ошибка авторизации MODX Manager;
- Wrong Bin file! - Не найден бинарный файл утилиты CWEBP;
- Exec function disabled! - PHP функция EXEC отключена в PHP.INI;
- Bin file for: %PHP_OS% not found in ~Binaries/ - Не найден файл утилиты CWEBP для %операционной системы% сервера;
- Bin file not work! return code: %127% - Бинарный файл утилиты CWEBP вернул ошибку: %код ошибки%.
In some cases, you might also encounter issues with graphic editors not being compatible with WebP.
Solution
If you're struggling with the hassle of converting images to WebP format, there's good news - MODX has got you covered. You can use one of the many ready-made solutions available.
The first two solutions, webpgenerator and modxWebpConverter, are great options, but be aware that they may not work on all hosting platforms. If you're looking for a more reliable solution, consider OptiPic CDN, which offers a cost-effective and easy-to-use service that can convert outdated image formats to WebP.
Discover more: How to Use Inspect Element to Find Answers

If you're feeling adventurous, you can even write your own solution as a snippet or plugin. For inspiration, here's an example of working code:
- webpgenerator - a budget-friendly extension (290 р.) for converting images to WebP format.
- modxWebpConverter - a free plugin that converts graphic files to WebP format.
- OptiPic CDN - a budget-friendly CDN service that converts outdated image formats to WebP on the fly (connects to MODX via a convenient module).
To make the process of supporting WebP on MODX Revolution as seamless as possible, you can use a plugin that creates actual copies of your images in a special subfolder. This way, you can keep loading your beautiful JPEG or PNG images, and the plugin will take care of creating the necessary WebP versions.
Installation and Setup
To install the WebP converter plugin in MODX Revo, you'll need to create a new folder called /connectors/converter/ in the root directory of your site.
You'll also need to download the contents of the modxWebpConverter repository from GitHub and place them in the newly created folder.
After setting up the plugin, head to the MODX Revo control panel and navigate to the System Events tab.
Here's a list of system events you'll need to check:
- OnManagerPageBeforeRender - This event is triggered in the manager controller, before the content is rendered.
- OnWebPagePrerender - This event is triggered after all tags on the page have been processed, but before they're sent to the browser.
- OnSiteRefresh - This event is triggered every time the cache for the entire site is cleared.
- OnTemplateSave - This event is triggered after a template has been saved.
- OnChunkSave - This event is triggered after a chunk has been saved.
- OnPluginSave - This event is triggered after a plugin has been saved.
- OnSnippetSave - This event is triggered after a snippet has been saved.
- OnTemplateVarSave - This event is triggered after a template variable has been saved in the database.
- OnDocFormSave - This event is triggered after a resource has been saved in the manager through the edit form.
After saving the plugin, a new link called "WEBP Converter" should appear in the MODX user menu.
Converter Operation

The converter operation is a crucial part of the WebP MODX plugin. It's designed to work in three different modes, which can be accessed by clicking on the WebP Converter link in the MODX user menu.
The first mode is creating a list of JPEG and PNG files to be converted, skipping files that have already been converted. The second mode is converting files from the list, displaying the number of files in the queue for processing. The third mode is clearing the /webp/ directory, removing any leftover files from deleted copies and resetting the plugin's cache.
In the conversion mode, the plugin works in parallel, allowing you to continue managing your site while the conversion takes place. You can also increase the number of concurrent threads by clicking on the "WEBP Converter" link multiple times, but be aware of the potential impact on your server's performance.
You might enjoy: Why Do Webp Files Exist
Конвертер для Revo
The WebP converter for MODX Revo is a game-changer for web developers. WebP is a modern graphic format developed by Google in 2010 that's supported by all modern browsers except IE.
For more insights, see: What Is the Modern Breakpoint for Responsive Css

The main reasons to use WebP are its smaller file sizes, which are more than twice as small as JPEG or PNG files, and the fact that Google Page Speed scores increase when using this format.
However, MODX Revo lacks proper support for WebP, and while there are plugins like thumbOf that can create WebP copies, they don't check if the browser supports the format. Not all graphic editors work with WebP either.
To make things easier, we can create a transparent support system for WebP, so you won't have to worry about extra copies of graphic files on your server. You'll still upload images in JPEG or PNG formats, and the plugin will create and manage the WebP copies in a separate folder.
To set up the WebP converter in MODX Revo, you'll need to create a folder called /connectors/converter/ in the root directory of your site and download the contents of the https://github.com/commeta/modxWebpConverter repository into it.
Here are the system events you need to check in the MODX Revo control panel:
- OnManagerPageBeforeRender - Runs in the manager controller, before the content is rendered.
- OnWebPagePrerender - Runs after all tags on the page are processed, but before they're sent to the browser.
- OnSiteRefresh - Runs every time the cache for the entire site is cleared.
- OnTemplateSave - Runs after a template is saved.
- OnChunkSave - Runs after a chunk is saved.
- OnPluginSave - Runs after a plugin is saved.
- OnSnippetSave - Runs after a snippet is saved.
- OnTemplateVarSave - Runs after a template variable is saved to the database.
- OnDocFormSave - Runs after a resource is saved in the manager through the edit form.
After saving the plugin, you'll see a link called "WEBP Конвертер" in the right top menu of the MODX Revo control panel.
Principles of Converter Operation

The converter operation relies on the cwebp utility developed by Google. This utility is specifically designed to handle cases like this.
The cwebp utility has several options that can be used to customize the conversion process. For example, the -metadata none option tells the converter not to copy metadata from the original file.
The -m option is used to specify the compression method, with values ranging from 0 to 6. A higher value means slower compression but higher quality. In one of the examples, the -m 6 option is used, which is the highest value available.
The -q option is used to specify the quality of the compressed file, with higher values indicating higher quality. In one of the examples, the -q 70 option is used, which is a high quality setting.
Here are the options used to customize the conversion process:
- -metadata none: Don't copy metadata from the original file.
- -m 6: Use the highest compression method (slow compression, high quality).
- -q 70: Use a high quality setting (70% quality).
The converter also has options to customize the alpha channel compression. For example, the -alpha_q 85 option is used to specify the quality of the alpha channel, with a value of 85 indicating high quality. The -alpha_filter best option is used to specify the method of predictive filtering for the alpha plane, with "best" indicating the highest quality.
On a similar theme: Best Web Development Programming Language
Режимы Работы Конвертера

The WebP converter has three modes of operation. The first mode creates a list of JPEG and PNG files to be converted, skipping already converted files until the original files are updated.
There are three modes of operation for the WebP converter. The second mode converts files from the list, displaying the number of files in the queue for processing in the MODX USER MENU.
You can run multiple instances of the converter in different browser tabs, but be aware of your server's physical capabilities, as this can slow down performance. The third mode cleans up the /webp/ directory and resets the plugin's cache.
The converter can run in multiple threads, but only up to three by default. You can increase this limit without opening multiple browser tabs.
Here are the three modes of operation in more detail:
HTML and Site Optimization
When you're optimizing your site, it's essential to make sure your HTML code is also up to speed. The WebP MODX plugin can help with that by automatically replacing JPEG and PNG images with the more efficient WebP format in your site's HTML code.
Consider reading: Web Designers Code
As the plugin analyzes your HTML code, it looks for JPEG and PNG files in three specific places: the IMG tag's SRC attribute, the IMG tag's SRCSET attribute, and inline CSS STYLE selectors that point to resources.
If the plugin finds a file with a copy in the /webp/ directory, it will replace the original file with the WebP version, but only if the browser supports WebP.
The plugin's results are cached until the MODX system cache is cleared or a resource, chunk, plugin, snippet, or TV field is saved in the MODX manager.
To test and optimize your site, use tools like Google PageSpeed Insights and Lighthouse. These tools can help you see how much your site's loading time has improved after implementing WebP and evaluate your Core Web Vitals scores.
If this caught your attention, see: Host Django Site
Featured Images: pexels.com

