Open westonruter opened 3 years ago
Thanks for filing. This looks very useful! Is the placeholder image URL scheme an official API?
De facto official, I believe. See https://stackoverflow.com/a/2068371/93579.
If the amp-youtube amp-img[data-hero]
is identified as a hero image, then the PreloadHeroImage
transformer should also add a link[rel=preconnect]
for https://i.ytimg.com
. This will also improve the performance of loading the YouTube iframe.
This further relates to https://github.com/ampproject/amp-toolbox-php/issues/10: if we identify that amp-youtube
is in hero position, shouldn't we also add a link[rel=preconnect]
for https://www.youtube.com
?
The poster image URLs are also utilized in the lite-youtube-embed
facade.
Did you test whether this causes a double download of the poster image because of origin keyed caching?
That's a great point. No, I didn't test that.
I looked into this. It doesn't matter in this case as the AMP runtime also injects the poster image (which causes a double download anyway).
Great! (?)
Something that we do in the WordPress plugin when converting a YouTube iframe into
amp-youtube
is automatically supply the poster image placeholder, which can greatly reduce LCP since YouTube videos are heavy andamp-youtube
doesn't implement a facade.So instead of:
We generate:
With Optimized AMP and hero image prerendering, this is further optimized as the poster becomes a hero image:
(Caveat: It seems currently only the PHP implementation of
PreloadHeroImage
is identifying such placeholders as hero image.)It seems generally useful to have an optimizer transformer that does this for all
amp-youtube
components that lack aplaceholder
, and to do the same for other popular components which have an easily-determined poster image.