Peleke
August 26, 2021, 3:12pm
1
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?
Is this on 3.6 alpha?
If yes, I have a feeling this has something to do with it:
/**
* Generates a list of allowed attributes
* for video iframes
*
* @param array $attr
* @return array
*/
public static function videoAttr($attr): array
{
return [
// allow fullscreen mode by default
'allowfullscreen' => $attr['allowfullscreen'] ?? true,
'class' => $attr['class'] ?? null,
'height' => $attr['height'] ?? null,
'width' => $attr['width'] ?? null,
];
}
async
and defer
are not valid iframe attributes?
1 Like
Peleke
August 26, 2021, 6:20pm
5
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 ·