Image Optimization with Lighthouse to Serve Images in Modern Formats

Image Optimization with Lighthouse to Serve Images in Modern Formats

Maximize web performance by serving images in AVIF and WebP formats using Lighthouse's insights

Posted by Joe Dodds on May 27, 2023

Modern web performance is largely driven by the optimization of resources, with a considerable focus on images. Images represent a significant proportion of the data used by websites. Therefore, serving images in the most efficient formats can have a profound impact on site performance, user experience, and SEO ranking. Google's Lighthouse auditing tool provides critical insights to help achieve this optimization, one of which is the opportunity to "Serve images in modern formats." This feature, situated in the Opportunities section of the Lighthouse report, identifies all images on a site that are in older formats, suggesting potential performance gains that could be achieved by serving these images in modern formats, such as AVIF and WebP.

The Problem with Traditional Image Formats

Many websites still use traditional formats like JPEG, PNG, and GIF for their images. While these formats have their strengths and have served the web well for years, they are not as efficient as some of the modern formats when it comes to compression and quality. These older formats often lead to larger file sizes, which can slow down site performance, particularly for users with slower internet connections or on mobile devices.

The Promise of Modern Image Formats

In recent years, two formats have emerged as superior options for web images: AVIF and WebP.

AVIF, or AV1 Image File Format, is based on the AV1 video coding format developed by the Alliance for Open Media. It offers significant compression gains compared to older formats, meaning it can deliver high-quality images at much smaller file sizes. This makes AVIF an excellent choice for websites with heavy image content.

WebP, developed by Google, also offers impressive compression capabilities, particularly for images with transparency (alpha channels), where it significantly outperforms PNG. This format supports both lossy and lossless compression, allowing developers to balance image quality and file size according to their needs.

Identifying Opportunities with Lighthouse

The Lighthouse tool is instrumental in spotting opportunities for improving site performance. By analyzing a site's resources, it provides a list of all images currently served in older formats. This detailed report shows the potential savings in kilobytes (KB) or megabytes (MB) that could be gained by converting these images to modern formats.

For each image, Lighthouse calculates the difference between the current file size and the estimated file size if it were served in a modern format. It then presents these potential savings, offering developers clear guidance on the possible performance gains that could be achieved.

Implementing the Change

After identifying the images to convert, the next step involves generating AVIF or WebP versions of these images. There are several tools and libraries available for this, including Squoosh, an online image compression web app developed by Google, and ImageMagick, a robust software suite that handles image conversion and manipulation.

Once the images are converted, they need to be served to users in a way that is compatible with their browsers. This often involves using the 'picture' HTML element or similar methods, which allows different versions of an image to be served according to the browser's capabilities.

Conclusion

Serving images in modern formats is a crucial component of web performance optimization. By leveraging the Lighthouse's "Serve images in modern formats" feature, web developers can readily identify the potential savings offered by these formats. Embracing AVIF and WebP doesn't just improve site performance; it enhances the user experience and could positively impact SEO rankings. Modern image formats are here to stay, and leveraging them to their full potential is an opportunity that should not be missed.

Imagelato helps you host and manage images in all formatsimagelato

Sign up for our newsletter

Recent articles