Skip to content

Instantly share code, notes, and snippets.

@myfreeer
Created March 12, 2017 05:43
Show Gist options
  • Save myfreeer/2250892d9e8fe5d080e71defbd17da5e to your computer and use it in GitHub Desktop.
Save myfreeer/2250892d9e8fe5d080e71defbd17da5e to your computer and use it in GitHub Desktop.
Full preload a html5 video
javascript:void(Array.prototype.slice.call(document.getElementsByTagName('video')).map(function(a){return!(a.src&&a.src.match('blob'))&&fetch(a.currentSrc||a.src).then(function(b){return b.blob()}).then(function(b){return a.src=URL.createObjectURL(b)})}))
const makePreload = video => !(video.src && video.src.match('blob')) && fetch(video.currentSrc || video.src).then(response => response.blob()).then(blob => video.src = URL.createObjectURL(blob));
//[...document.getElementsByTagName('video')].map(makePreload);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment