Lightweight video facade
Load the heavy player only when the visitor clicks.
HTML · Lightweight video facadeAdvanced
<button type="button" class="yt" data-id="VIDEO_ID" aria-label="Play video: Intro">
<img src="https://img.youtube.com/vi/VIDEO_ID/hqdefault.jpg" alt="" width="480" height="360" loading="lazy">
</button>
<script>
document.querySelector('.yt').addEventListener('click', function () {
var f = document.createElement('iframe');
f.src = 'https://www.youtube-nocookie.com/embed/' + this.dataset.id + '?autoplay=1';
f.title = 'Intro';
f.allow = 'autoplay; encrypted-media';
f.allowFullscreen = true;
f.width = 480; f.height = 360;
this.replaceWith(f);
});
</script>videofacadeperformanceiframe