Wagtail Lite YouTube Embed

A Wagtail embed finder to use lite-youtube for more efficient and private YouTube embeds.

When it comes to loading times and invasive embeds, there's nothing quite like a YouTube embed. The stock YouTube embed is full of trackers and complex javascript, all of which impacts usability and page performance. Worse still, all of this happens regardless of whether the user actually plays the video.

<aside>

Performance concerns aside, there may also be legal concerns.

</aside>

It's not super common, but there are a few places (example) on my blog where I embed YouTube videos. But if you notice, they all load incredibly fast, with minimal performance impact - but how?

#lite-youtube-embed

Whilst I'd love to take it, the credit actually goes to lite-youtube-embed, a tool which postpones the stock YouTube embed until the user requests it. Until then, it's just an image and a play button. Check out this demo, which proves it.

#wagtail-lite-youtube-embed

At the time of writing, my website is built with Wagtail, so I wanted an easy way to plug lite-youtube-embed into Wagtail's existing embed functionality. Unfortunately for me, one didn't exist (YouTube is natively supported, but it uses the stock embed) - so I wrote my own.

With just a few lines of code, I've overriden the stock YouTube embed with one which uses lite-youtube-embed, and no horrible YouTube trackers!

<extension>

By default, the video title isn't shown in the player embed - only the thumbnail. I had to do some tweaks to make that work

</extension>

Share this page