0

Was just thinking about this today and it made me curious.

If I have some elements or divs on a site, such as a video tag, if I set this video tag to display: none; in a media query for mobile users.

When those users view the site on their devices, will the site still load in the video and its elements, then hide them? Or does it prevent the elements from being loaded in?

Will it affect load time?

I have a site with html5 video for desktop and when scaled down it replaces these elements with a gif for mobile devices since html5 cant auto play on ios devices. Does that mean by selecting display none it is preventing the videos or whatever other elements from affecting the mobile load time?

h0bb5
  • 609
  • 1
  • 7
  • 22
  • 1
    Videos don't load automatically on mobile to prevent the user from paying for bandwidth they never use. – zzzzBov Jan 14 '15 at 23:59
  • 1
    @zzzzBov yes... thanks for that, completely unrelated to my question – h0bb5 Jan 15 '15 at 00:05
  • "When those users view the site on their devices, will the site still load in the video and its elements" I was addressing this mistaken assumption. The site won't **still** load in the video because it didn't to begin with. – zzzzBov Jan 15 '15 at 00:08
  • @zzzzBov I already addressed that.. if you would have kept reading you would have saw "I have a site with html5 video for desktop and when scaled down it replaces these elements with a gif for mobile devices since html5 cant auto play on ios devices" – h0bb5 Jan 15 '15 at 00:21

1 Answers1

1

This is situation and browser dependent. In many cases a hidden asset won't be downloaded but it could be if the browser thinks its going to be used. This is an older question but it addresses what you are after:

Does "display:none" prevent an image from loading?

I would guess on mobile that the download would be deferred. I know for sure that display:none; images are deferred on current chrome on android and html5 video is probably the same.

Community
  • 1
  • 1
Joe W
  • 2,773
  • 15
  • 35