Skip to content

Instantly share code, notes, and snippets.

View tavanarad's full-sized avatar

Morteza Tavanarad tavanarad

View GitHub Profile
@tavanarad
tavanarad / lazy-video-loader.js
Created March 1, 2019 01:39 — forked from benrobertsonio/lazy-video-loader.js
Lazy Loading Video Based on Connection Speed
class LazyVideoLoader {
constructor() {
this.videos = [].slice.call(document.querySelectorAll('.hero__bgvideo'));
// Abort when:
// - The browser does not support Promises.
// - There no videos.
// - If the user prefers reduced motion.
// - Device is mobile.
if (