Compress Image Files To Improve Website Performance

by | Web Development, Website Functionality

Compress image files to improve website performance and make Google’s PageSpeed Insights happier, too.  Compression in this instance refers to non-lossy reduction of the image file size (JPG and/or PNG formats) by removing metadata, gamma information and unnecessary color profiles.  This type of file compression does not degrade image quality.  To handle the compression, two WordPress plugins were trial tested as well as a an open source (Mac) desktop software solution.

The WordPress plugins were quite slow since they performed compression on the server at image upload time and both had limitations that could only be removed by paying for the premium version.  Limitations included limits on the actual total number of images that could be compressed, disabling of batch processing, and no compression of the original uploaded image (only the thumbnail, small, medium and large size images generated by WordPress were compressed).   In both cases, the premium versions of the plugins required much-too-expensive monthly subscriptions for processing images.

Screen shot of ImageOptim software used to compress image files

A search for a desktop software method to perform non-lossy compression on website images turned up the open source, free of charge, ImageOptim software for Mac.  ImageOptim opens a window on the desktop where JPG and PNG files can be dragged and dropped for compression.  The files are actually compressed in place at their original location, so there’s no need to drag the compressed version back to the original folder.  Compression of JPG images is generally very fast, but PNG compression can take a quite a big longer.  However, PNG file size reduction can be much more significant than JPG and unchecking a couple of options speeds things up considerably.  Unchecking the PNGOUT and Zopfli options in preferences produced compressed PNG files much faster and they were only about 2% larger than leaving the options checked.

Using the ImageOptim compression software also has the added benefit of compressing the files before they’re uploaded to the server.  This method also works for non-WordPress websites.

Conclusion

For WordPress sites, using a limited (free) plugin (such as WP Smush) to compress image files in combination with the desktop software might be a good solution.  When tested, an already compressed PNG file was further reduced with the WP Smush plugin by 2% when WordPress generated the thumbnails and other image sizes.