Mozilla has posted its intent to ship JPEG XL support in Firefox, with Chrome also intending to ship and Safari already having a partial implementation, meaning cross-browser support is expected before the end of the year. The decoder, jxl-rs, was built in Rust by Google Research after Mozilla challenged them to create a safe, performant alternative to the original 100,000-line C++ decoder that raised security concerns. The Rust implementation supports progressive rendering, a feature Safari's JPEG XL support lacks. The piece also compares JPEG XL against AVIF across lossless, high-quality, and web-quality use cases, showing trade-offs in file size and use-case fit between the two formats.

3m read timeFrom hacks.mozilla.org
Post cover image
Table of contents
Shipping JPEG XL securelyProgressive renderingJPEG XL vs AVIFAbout Jake Archibald

Questions this post answers

Is Firefox going to support JPEG XL images?

Yes, Firefox has posted its intent to ship JPEG XL support, built on a new Rust decoder called jxl-rs developed by Google Research. Chrome has also announced intent to ship, and Safari already has a partial implementation, so cross-browser JPEG XL support is expected before the end of the year. Track browser image-format rollouts like JPEG XL support as they land, on daily.dev.

Why did Firefox rewrite its JPEG XL decoder in Rust instead of using the existing C++ implementation?

Firefox had experimental JPEG XL support behind a flag since 2021, but the original decoder was about 100,000 lines of multithreaded C++, creating security and attack-surface concerns. Mozilla challenged the JPEG XL team at Google Research to build a safe, performant, compact, and compatible decoder in Rust, resulting in jxl-rs, which now powers Firefox's JPEG XL support, including progressive rendering that Safari's implementation lacks. Developers weighing decoder security trade-offs can follow Rust rewrites like jxl-rs on daily.dev.

Should I use JPEG XL or AVIF for images on my website?

It depends on the use case: AVIF tends to produce smaller files for web-quality photographic images with sharp edges and flat surfaces, while JPEG XL excels at lossless imagery, progressive rendering, and recompressing existing JPEGs without quality loss. For example, at a very high SSIMULACRA 2 quality score of 80, an AVIF was 227 kB versus 264 kB for JPEG XL, but at lossless quality JPEG XL was smaller (1.45 MB vs 1.76 MB AVIF). Testing with representative images at your target quality is recommended. Compare image format trade-offs like JPEG XL versus AVIF before picking one for your site, via daily.dev.