Defer attribute for the video helper

As I want to increase my Google Lighthouse score for performance I want to load embedded videos “deferred” with an additional attribute which I tried to add like this in the /site/snippets/blocks/video.php:

<?= video($block->url(), [ ], [ 'async' => true, 'defer' => true ]) ?>

Sadly I can see no difference. How can I do it?

For browsers that already support this:
Otherwise you can use a JS library like: lozad.js/index.html at master · ApoorvSaxena/lozad.js · GitHub

Is this on 3.6 alpha?

If yes, I have a feeling this has something to do with it:

async and defer are not valid iframe attributes?

1 Like

Yes, I am using alpha 3.6 and have changed the parameters to ‘loading’ => ‘lazy’ but YouTube seems still to be a big problem:

@rasteiner This is indeed the problem and I created a PR for it (tested on my installation): Add loading as an allowed attribute to the video helper by MaluNoPeleke · Pull Request #3654 · getkirby/kirby ·