With ever more internet activity taking place over mobile connections, it makes sense to optimize website content as much as possible so that content loads as quickly as possible. One of the best places to make savings is amongst images, as they are the “heaviest” content on a regular website. (Aside from video, of course.)

A complicated algorithm in server-side tools like GD or ImageMagick means that even where images are optimized as much as possible in (for example) Lightroom, compression when uploading to CMS like WordPress can sometimes create images which are actually larger than the originals.

A tip for WordPress developers is to use the jpeg_quality hook to set a lower quality setting than WordPress’ default setting of 90%. Detailed research and testing by Joe McGill in preparation for this proposal to WordPress Core indicates that a value of around 82% produces significant size savings, whilst remaining within acceptable optical similarity limits.

My own brief testing this morning shows that a value of 80% is fine too: by setting this value to apply to JPGs generated on this website, I could reduce the total size of images added to the site in December 2015 from 135mb to 101mb, using the following code in my functions.php and then re-generating the thumbnails using this plugin.

Update July 2018: if you’re using the Timber plugin, you can use the wp_editor_set_quality hook as well as the WordPress standard jpeg_quality hook.

Leave a Reply

Your email address will not be published. Required fields are marked *

For security, use of Google’s reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

This site uses Akismet to reduce spam. Learn how your comment data is processed.