How to Optimize Background Videos and Hero Media
A looping video behind the headline can make a homepage feel alive. It can also be the largest, slowest thing on the page, and a poor fit for phones. If you want hero media, set it up carefully.
Ask whether you need video
A video should earn its place. Consider a sharp image or a short animation instead, especially if the video is purely decorative. A hero image is simpler, loads faster, and works for everyone. See hero section design best practices.
If you use video
Keep it short and small
- Aim for a loop of a few seconds to perhaps ten seconds
- Reduce resolution to what the layout needs, often 1280 pixels wide or less
- Remove the audio track from decorative video
- Use efficient modern encoding, and compress well
A decorative background video should not weigh more than a few megabytes. Smaller is better.
Provide a poster image
Set a poster image so something appears immediately. Make that image your largest contentful element, optimized and loaded early, so the page does not wait for the video. See how to improve Largest Contentful Paint.
Load it after the important content
Start fetching the video after the page is usable. Use preload="none" or metadata where appropriate, and consider starting playback only once the page has loaded.
Do not autoplay on mobile data without thought
Many visitors are on limited data plans. Consider serving a still image on small screens or when data saving is requested, rather than the video.
Make it accessible
- Pause control. Content that moves automatically for more than five seconds should have a way to pause, stop, or hide it, under WCAG success criterion 2.2.2. See website accessibility basics
- Respect reduced motion. Show a still image when the visitor has asked for less motion. See reduced motion and animation accessibility
- Contrast. Check that text over the video stays readable at every moment. Add an overlay if needed. See color contrast for accessible websites
- No audio autoplay.
Technical settings
Background videos usually need to be muted, set to loop, and set to play inline so that phones do not open them in a full-screen player. Provide more than one format if you need broad support.
Other hero media
- Animated images: avoid large GIFs, which are very heavy. A short video is usually much smaller
- Sliders: they often add weight without improving results. See accessible carousels and sliders
- Embedded players: use a facade or a click-to-load approach. See how to optimize video and embeds
Test on real devices
Check load time, battery use, and smoothness on a mid-range phone on a normal connection.
Common mistakes
- Using a huge, unoptimized file
- No fallback image
- No pause control
- Text that is hard to read over moving footage
Text can also hold up the page if fonts load badly. Read font-display and flash of unstyled text.