Redoing how the frontpage header videos load
authorLaury GvR <laury@gaslightmedia.com>
Wed, 14 Mar 2018 18:38:29 +0000 (14:38 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Wed, 14 Mar 2018 18:38:29 +0000 (14:38 -0400)
commit6d8f61974e7c078732b8b1f303933914d6bf8410
treeecfbfaa74684ed53478d1b089500f59a1c1886e3
parent66e6b284654622a9599892a1234a871128ce495f
Redoing how the frontpage header videos load

In short: custom pre-load image is shown while the video loads, and
the only video loaded is the one appropriate for the window size on
load

Previously, both Desktop and Mobile videos would load for this site,
and only one would be shown, resulting in slowed load times.

The first method tried was switching out the source based on the
window width; this required a single video container as opposed to
two, and it worked fine, with the exception of the container not
technically having any 'content' on load, leading to disruptively
jumping content without a fallback or poster image in place.

Since we do not have a fallback image, I created a simple one that
says the video is loading.

After discussing this problem with Anthony, we decided to go with
a method that still uses two different containers, but uses
preload="none" to avoid the video loading, and then .load() to load
the actual video if the window size is right. The only problem
remaining was that now both elements would show without a class
like show-for-medium-down, but with those classes, when someone
resizes from large to small no video is shown at all.

However, since the possibility of problems is relatively small
(only when going from tablet portrait to landscape, and from
opening the site in a small window and resizing it to be large),
this too is something we will at this point not be spending time
to resolve.

Some attempt was made at creating some code that handles source
loading based on window resize, but this has been abandoned on
account of window resizing not being our concern (and to save time)
assets/videos/header-video-preload-image-v2.png [new file with mode: 0644]
assets/videos/header-video-preload-image.png [new file with mode: 0644]
js/app.js
js/custom/pageSetup.js
parts/header-video.php