Skip to content
ServicesPortfolioBlogAboutContactPolski

Blog3 min read

The video on phones, half the weight

344 KB

is what the video weighs on a phone, instead of 795 KB

In short

A video plays at the top of my website. A phone only showed a narrow vertical strip of it, but downloaded the whole thing. I cut that strip into a separate file: 344 KB instead of 795 KB, the same frame on screen, and the page on a phone now weighs 740 KB instead of 1180 KB.

The video on the first screen is a deliberate choice. Without it the page scored 95–100 in PageSpeed, with it 92–93, and a still frame on its own looked flat. I decided the video was worth those few points. That does not mean a phone should download more than it needs.

Where the kilobytes went

The video is 1600 × 900 pixels, as wide as a computer screen. A phone held upright shows only a narrow vertical strip of it, less than half the width. The rest is cropped and nobody sees it. The browser still downloaded the whole file, 795 KB.

The solution: a separate file for phones

From the original I cut a 720 × 900 pixel strip that contains everything visible on a phone, without the audio track. Where to cut mattered. On a phone the video is positioned at 68% of the spare width, so the cut-out starts at the same place. The frame on screen looks identical; only the file size differs.

The file is chosen by the browser itself, not by a script. The video element has two sources: a screen up to 500 pixels wide takes the phone version, a larger one takes the full version. There is no extra code here that could break or delay the start of the video.

The result

BeforeAfter
Video on a phone795 KB344 KB
Whole page on a phone1180 KB740 KB
Lighthouse (mobile)91–9394–99
LCP2.9–3.1 s1.8–2.8 s

I give the results as ranges because mobile measurements vary between runs. I measure several times, before and after each deployment.

The maintenance cost

This solution has one drawback: there are now two files instead of one. If I change the video, I also have to cut the phone version again, or phones will show the old video. That is why I saved the command that makes the cut-out in the code, right next to the video. The next person working on it does not have to work it out again.

If your website loads slowly on a phone and you do not know why, get in touch. Usually one or two files are to blame, and they can be slimmed down without changing how the site looks.