Hunting For the Perfect Recipe on Image Speed Optimization

TheMarquis

Elite Member
Executive VIP
Jr. VIP
Joined
May 17, 2013
Messages
3,970
Reaction score
24,169

wile-e-coyote-run.gif

In this short tutorial, I will show how to convert&optimize your images into WebP, save hosting space and increase your WordPress site's performance. Let's say you want to bulk convert 50GB of images.

NOTE 1: This is an integral part of the site speed optimization, but it doesn't cover the entire performance optimization process. You have to ensure your entire site is optimized (scripts, etc.) and use quality hosting. As usual, I recommend using NVMe as the best option.

What is WebP?

WebP is the most used image format nowadays for speed improvements. Google developed it in 2010. It provides a smaller size and better quality than other popular formats such as JPEG, PNG, and GIF.

The WebP format uses lossy and lossless compression to achieve higher compression ratios than JPEG or PNG images of the same quality setting and resolution.

Backup-1st.jpg


Note 2: Do a backup of your site's files in case of any issue.


Solution I - Do it the Coyote style, make that fish swim faster.

Download and install Google's WebP Converter command-line tool and create a .bat file using the following code:

Code:
@Echo off
 for %%f in (*.png) do cwebp -q 74 %%~nf.png -o %%~nf.webp
 del *.png
 for %%f in (*.jpg) do cwebp -q 74 %%~nf.jpg -o %%~nf.webp
 del *.jpg
 for %%f in (*.jpeg) do cwebp -q 74 %%~nf.jpeg -o %%~nf.webp
 del *.jpeg

Insert the .bat file in a folder with png, jpg, or jpeg files, and it will convert them all.

Attention: This script deletes the original file! Make sure you saved a copy of the media folder in another place!



Solution II - Here is how to do it faster than a running Coyote, not even a bunny could get away:

If you cannot install Google's WebP converter on your hosting, you have to rent a VPS for a few days.

  1. Rent a quality VPS (DO/Hetzner/Interserver/Vultr). For a 50GB size, you need to rent around 100GB-150GB VPS server (temporary files, buffer, etc.).
  2. Go on Google and search for: "convert the PNG and JPEG images to the ".webp" format using the command-line utility of WebP" (you will find a ton of cwebp command-line utility's tuts).
  3. Install the required codec.
  4. Upload the images folder of your WordPress site on the VPS.
  5. Run the batch process. It will take some time to convert, depending on the size number of the images and the VPS power.
  6. Download the folder from the VPS and re-upload it to the original location (your WordPress site) or, even better, on your CDN.
That-s-all-folks.webp


A special mention for the creative support goes to @RoiBox
 
Nice guide! I'm currently using a CDN provider for some websites to get this done, while CDN is not the best solution for most websites it's an easy way to get this running without technical skills. Some also support AVIF, but it's not supported by a lot of browsers yet.
 
It depends. I had only good results with CDN in the past, but this is just in my case.
Yes, I was thinking to mention AVIF in the thread: It is, indeed, the best of the best, but still not supported on a large scale. Maybe in the next years.
 
To further add to optimization, the website should serve the image based on device resolution (using CSS or JS or PHP if browser returns client hints).
 
Yes, Shortpixel IO would be in the top of the list.
Mine as well!

I install it on every single website I work for my SEO clients.

WebP express is also good.
Love it!

But, when it comes to free image optimization plugins, I prefer Flying Images.

But I am not a fan of plugins. The fewer, the better.
As a WP speed optimization enthusiast, I am NOT a big fan of plugins either but, when it comes to automating long and tedious tasks or handling these types of issues on large sites, I prefer using a plugin.

Also, it will help clients/webmasters move forward. Especially, if they plan to expand their site (add more images).
 
Back
Top