Mozilla Launches Project to Speed Up JPEG Image Handling

by Ostatic Staff - Mar. 06, 2014

If you've done any web development work, you know that JPEG images can be one of the most common page elements to slow down performance. Reducing the file size of JPEG images may sound like a trivial goal, but reliable methods for doing so can speed up web performance significantly. With that in mind, Mozilla has launched a new project called mozjpeg that is targeted to compress JPEGs more efficiently, leading to better page performance.

"The goal is to provide a production-quality JPEG encoder that improves compression while maintaining compatibility with the vast majority of deployed decoders," says Mozilla's announcement of the project, which adds:

"Production JPEG encoders have largely been stagnant in terms of compression efficiency, so replacing JPEG with something better has been a frequent topic of discussion. The major downside to moving away from JPEG is that it would require going through a multi-year period of relatively poor compatibility with the world’s deployed software. We (at Mozilla) don’t doubt that algorithmic improvements will make this worthwhile at some point, possibly soon. Even after a transition begins in earnest though, JPEG will continue to be used widely."

"Given this situation, we wondered if JPEG encoders have really reached their full compression potential after 20+ years. We talked to a number of engineers, and concluded that the answer is “no,” even within the constraints of strong compatibility requirements."

 JPEG images have been around since 1992, and, as is true with Flash video, became a widely used standard as the web grew up. Mozilla has already delivered on the first step of its Mozjpeg project:

"What we’re releasing today, as version 1.0, is a fork of libjpeg-turbo with ‘jpgcrush’ functionality added. We noticed that people have been reducing JPEG file sizes using a perl script written by Loren Merritt called ‘jpgcrush’, references to which can be found on various forums around the Web. It losslessly reduces file sizes, typically by 2-6% for PNGs encoded to JPEG by IJG libjpeg, and 10% on average for a sample of 1500 JPEG files from Wikimedia. It does this by figuring out which progressive coding configuration uses the fewest bits. So far as we know, no production encoder has this functionality built in, so we added it as the first feature in ‘mozjpeg’."

If you're interested in getting invovled with the mozjpeg project, there is a GitHub site with relevant links and information, found here.