Andrea Casarin

Andrea Casarin

Published on: 4/30/2019, 4:14:10 PM - Reading time: 2 minutes

Page Speed: S3 recursive image optimization

I have been recently involved in a website optimization project for SEO purposes. One of its major steps was the (lossless) image optimization to improve performances and, of course, to make sure to be Google Page Speed friendly.

Google Page Speed Insights

PageSpeed Insights is a tool from Google which “analyzes the content of a web page, then generates suggestions to make that page faster”.

Page Speed S3 recursive image optimization

Photo by Jannik Selz on Unsplash

It’s the base index for every website performace optimization and might as well be the index that Google uses in its search engine to adjust a website position to reflect its performaces (https://developers.google.com/speed/).

Let’s see how much we can improve.

Our own case

The website is a simple WordPress customization backed by AWS S3 for assets storage.

AWS S3 has no computational power but transfers between S3 and EC2 are very cheap (https://aws.amazon.com/s3/pricing/) so I decided to leverage an AWS EC2 spot instance to download each image, run the optimization and upload it back to the storage.

The process is pretty straightforward, but still a bit annoying to be done manually.

The automation

I created a simple bash script to automate the whole operation. I think may be useful for someone else out there, so here it is:

To use the script just download the Gist – make a backup -, make it executable – make a backup -, customize “credentials” and “configuration” sections – make a backup – and run it with:

./s3_recursive_image_optimization.sh

In case I forgot to mention: make sure to have a backup in case anything goes wrong.

Results

We are pretty happy with what we got, a straight “A”.

Also, since we automated to whole process, in case some images will not be optimized before being uploaded in the future we can still run the script again for the new ones.

If you’re wondering how your website is doing with Page Speed and other performance metrics, you can check it for free on GtMetrix: https://gtmetrix.com/.

Update: Janis from Experte wrote me an email to let me know about their pagespeed tool. It's great. It let's you test the entire website with a single click. Go check it out at https://www.experte.com/pagespeed.