Rene Juuse Rene Juuse - 28 days ago 8
HTML Question

What is the simplest or best way for preventing the background video from loading on mobile browsers?

I have a webpage which loads a video as a background. I want to prevent the video from loading on (at least some) mobile browsers. I have disabled displaying the video using the

@media
tag, but I think that this doesn't prevent the browser from loading the video.

@media screen and (max-device-width: 800px) {
#bgvid {
display: none;
}
}


I'd like to know how to prevent the video from loading on mobile browsers. It would be especially great if it could be done without using JavaScript.

Answer Source

Turned out that media tags were enough to prevent the loading of videos on mobile browsers (for devices that don't exceed the specified width).