You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Prioritize loading poster image of video LCP elements #1183
When a video is the LCP element and it has a poster image, we should prioritize the loading of that poster image with a fetchpriority=high preload link. This would be a simple addition to the existing logic that does the same for an img or background-image which is the LCP element.
This can be done as part of the Image Prioritizer plugin. See #1088.
Aside: if there is no poster, should an LCP video element also preload the video URL as well?
Aside: if there is no poster, should an LCP video element also preload the video URL as well?
Actually, preloading the video would be bad probably because it would try to fetch the entire thing, most likely. Maybe that would make sense if the video has autoplay, but otherwise there is a preload attribute on the video itself which we can set. If the video is in the initial viewport (for any breakpoint), then it should get preload=auto. If it is outside the initial viewport, then it should be preload=none.
If autoplay is enabled, then we'll need to check if it makes sense to preload the poster image, or if it makes sense to preload the video file itself. However, in the case of a video having multiple sources, then this would mean multiple preload links with different types.
In any case, whenever a preload link is added we should make sure that it gets the appropriate media attribute to specify the viewport range(s) in which the video appears in the initial viewport.
@westonruter I plan to address this in a separate issue and pull request to keep the current one on track for the next release. Let me know what you think.
Activity
westonruter commentedon Jul 18, 2024
Here's an example video element to test with:
thelovekesh commentedon Jul 18, 2024
Humm that sounds like a good idea.
westonruter commentedon Jul 18, 2024
Actually, preloading the video would be bad probably because it would try to fetch the entire thing, most likely. Maybe that would make sense if the video has
autoplay, but otherwise there is apreloadattribute on the video itself which we can set. If the video is in the initial viewport (for any breakpoint), then it should getpreload=auto. If it is outside the initial viewport, then it should bepreload=none.If
autoplayis enabled, then we'll need to check if it makes sense to preload the poster image, or if it makes sense to preload the video file itself. However, in the case of avideohaving multiplesources, then this would mean multiple preload links with different types.In any case, whenever a preload link is added we should make sure that it gets the appropriate
mediaattribute to specify the viewport range(s) in which the video appears in the initial viewport.westonruter commentedon Jul 24, 2024
Related to the
preloadattribute, I just found this interesting: https://kurtextrem.de/posts/improve-inp#videos--long-gray-tasks-%EF%B8%8Fthelovekesh commentedon Aug 25, 2024
@westonruter I plan to address this in a separate issue and pull request to keep the current one on track for the next release. Let me know what you think.