Many ways to schmooze PageSpeed

When building a new website you face enough problems to care about some speed test results. Once you're done, that could change.

Here is the PageSpeed result of this blog. Looks like I need to optimize the images.

Manual optimization

Maybe take the easy way and optimize the files before or after uploading? There are various desktop and cli tools to achieve the goal. Mix it with a cron job and you have a quick and dirty server side solution. Or just let you users do it. Most of these tools allow batching the process, so you it can be run once if you have - for example - all your blog post images together.

Layer 8 and foreign software

As a developer you don't trust users. What do users do with an optional repetitive task? They ignore it. Maybe extend the application to optimize the upload? Sure, but this only works if it's technically possible (closed source, 3. party software) and you boss agrees.

Use third party $ervices

Cloudflares Proxy takes care of many optimizations. Pro plan unlocks the "Polish" feature to gain speed. If you're willing to pay, this is my secret recommendation. Setup takes a minute and you don't have to touch your infrastructure.

ImageOptim on the other side, works different. It has an "on the fly" API that works by prefixing your image URLs like$YOUR_IMAGE_URL. They process and cache the images, but it comes with a price tag.

Deploy your own service

thumbor is an OSS and that works like ImageOptim but has some more features to explore. The project looks mature and is easy to setup. apsl maintains a stable and powerful Docker image.

Roll your own proxy

PageSpeed by Google is a module for Apache (binaries provided) and NGINX (Build from source) that handles optimization for you. The module is not just an image optimizer but a full stack optimization tool with following core features:

  • add_head
  • combine_css
  • combine_javascript
  • convertmetatags
  • extend_cache
  • fallbackrewritecss_urls
  • flattencssimports
  • inline_css
  • inlineimportto_link
  • inline_javascript
  • rewrite_css
  • rewrite_images
  • rewrite_javascript
  • Full filter list
Wrap up

PageSpeed seems to be the holy grail of website optimizers. Who could know better than Google? It's my favorite so far, and I'll build a reusable Docker image with NGINX and PageSpeed.