{% comment %}
Capture the original video tag and replace attributes so they become data-attributes,
then inject a .lazy class for yall.
{% endcomment %}
{% capture video_tag %}
{{ block.settings.video | video_tag: image_size: '1920x', autoplay: false, loop: true, muted: true }}
{% endcapture %}
{% assign lazy_video_tag = video_tag
| replace: 'src="', 'data-src="'
| replace: 'poster="', 'data-poster="'
| replace: '<video', '<video class="lazy" '
%}
{{ lazy_video_tag }}
<script type="module">
import { yall } from "https://cdn.jsdelivr.net/npm/yall-js@4.0.2/dist/yall.min.js";
yall();
</script>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter