
document.addEventListener('DOMContentLoaded', function () {
    const banners = document.querySelectorAll('.video-banner')

    Array.from(banners).forEach(function (banner) {
        const video = banner.querySelectorAll('video')[0];
        if (! video) {
            return;
        }

        const isVisible = video.offsetWidth || video.offsetHeight || video.getClientRects().length;
        if (! isVisible) {
            return;
        }

        Array.from(video.getElementsByTagName('source')).forEach(function (source) {
            source.src = source.dataset.src;
        });

        video.load();
    });
});
