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.


Performance concerns aside, there may also be legal concerns.


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?


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.


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!


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


Share this page