less than 1 minute read

In the process of making a new personal website I downloaded all my Medium posts with medium-2-md.

After I was all done porting posts across I plugged my website into Google’s Page Speed Insights to see how my website was fairing.

Desktop speed was looking good.

image-center

Mobile…. not so good.

image-center

The culprit? Some very large image sizes. Seriously, look at that 1.7 seconds and banner size.

image-center

So off I went to find a way to optimise all my images, which led me to optimize-images. A Python module which you can run through the command line. All you have to do is select an image or folder containing images.

To install:

pip3 install pillow optimize-images

Choose folder path filling in the blanks after ./:

optimize-images ./

After that I re-uploaded my now optimised images to GitHub. As you can see the results were pretty good for desktop.

image-center

And brilliant for mobile!

image-center

So there we have it. Optimising images with Python can be very quick and painless with massive gains for website speed, especially on mobile.