question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Audit: Serve `<video>` instead of animated GIFs

See original GitHub issue

Suggested audit Serve <video> instead of animated GIFs

Background

Animated GIFs are suboptimal for quality and performance. While they are a popular option for creative expression, they are awful for web performance - they’re large in size, impact cellular data bills, require additional CPU and memory, cause repaints and kill battery. Often, GIFs can be up to 10-12x larger than H.264 videos and take more energy to load and be displayed in mobile browsers. Those resources are being spent on something that has severe color limitations.

Using the <video> tag is significantly better for performance than animated GIFs. GIF sites have been shipped videos down instead of GIFs for years and back in 2014, Twitter even added animated GIF support using MP4s. They transcoded GIFs to MP4 on the fly, delivering them in <video> tags. This is a trend we’re seeing, but are still running into plenty of examples of sites accidentally shipping megs of animated GIFs down. The AMP team recently published a blog post that included 52MB of animated GIFs without realizing this.

Explanation of how it’s different from other audits

Current audits will capture unoptimized images and resources with large payloads but do not specifically call out animated GIFs that could be served down as <video> instead. This is a more targeted recommendation than current audits expose.

GIFs alone would not be flagged by this audit (we probably don’t want to flag 1x1 pixel tracking pixels…) so detecting if an image is an animated GIF using animated-gif-detector, is-animated or detectanimation might be worthwhile.

We’ve been considering implementing a feature policy for this idea so having something related in Lighthouse could be useful.

What % of developers/pages will this impact (estimates OK, data points preferred)

According to Android stable, GIFs account for approximately 4-5% of images loaded by Chrome. Although we do not have statistics on animated GIFs as a subset of this population, shifting animated GIFs over to video has the potential to impact a large number of requests on the web.

According to HTTP Archive, GIFs account for 23% of the total image formats being served on sites tracked by HA.

Advanced

If we wanted to do something really clever here, we could use FFMPEG.js (or similar) to try encoding animated GIFs as videos to demonstrate the byte savings, however, this is probably going to be too expensive for most pages.

What is the resourcing situation (who will create the audits, maintain the audits, and write/maintain the documentation)

This is an audit that could be authored by our Lighthouse contractor @wardpeet with input from myself and the image compression team (and Bonsai team). We have staffing to assist with documentation if needed and are planning to write up a best practice doc on using <video> vs animated GIFs for /web.

Do you envision this audit in the Lighthouse report or the full config in the CLI? If in the report, which section?

The default Lighthouse report. I would place this in the Opportunities section alongside other image optimization opportunities.

How much support is needed from the Lighthouse team?

Evaluation of the technical approach for the audit will be needed. Although there are OSS modules available to assist with detecting whether an image is an animated GIF, these may be 1) too large/unsuitable, 2) require additional thought on the performance of the solution for a page with a number of animated GIFs present.

Note: I noticed this audit was also filed in #2586. I am refiling here using the “new audits criteria” doc that the team published in the docs repo.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:34 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
malchatacommented, Jul 4, 2018

@abdonrd IIRC, autoplaying of videos may be blocked if you have data saver turned on. Try turning that off if you have it enabled.

2reactions
midzercommented, Jul 4, 2018

@abdonrd I’ve experienced letting browser load preview image via (now Chromium default) preload="metadata" to be less kbyte heavy in most cases than loading a custom poster.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Replace animated GIFs with video for faster page loads
Have you ever seen an animated GIF on a service like Imgur or Gfycat ... A failing Lighthouse audit, use video formats for...
Read more >
Use video formats for animated content - Chrome Developers
Learn about the efficient-animated-content audit. ... for animations and PNG/WebP for static images instead of GIF to save network bytes.
Read more >
Serve Videos Instead of GIFs - Hacker News
It looks like WebP Animation only supports I-frame like GIF Animation. I-frame only video should not be efficient so not suitable for video, ......
Read more >
Are animated gifs okay to have? - Accessible Web
Would a still image do? If not, think about providing an alternative or some way that users can forgo the animation or switch...
Read more >
Use video formats for animated content | Sitebulb
This means that the URL contains animated content in GIF format. ... being used for animated content, you should replace GIFs with video...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found