-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Facade Method for Rich Media iFrame Embeds #113
Comments
The biggest challenge is getting a representative thumbnail image in the facade, which for YouTube when done correctly requires hooking into YouTube's API which in turn requires an API key which is ... a hassle (I'm the dev of WP YouTube Lyte). |
@futtta what if this was left up to the user, to upload / assign an image from the media library? I don't think its too much of stretch. |
That's certainly a possibility, but that requires quite a few extra steps to be executed by the user as opposed to just adding a normal embed, so not really ideal? To be clear; one can with reasonable certainty "guess" the a thumbnail URL for normal YT video's (but not playlists) in low-ish resolution; always works, but the resolution is not great. there is also And there's also webp, but don't think every video has that available either; |
Fair point @futtta In my opinion, the performance benefits out weighs the strain on the user, especially if we can take steps to mitigate it, ie default placeholder if youtube thumbnail is no present, other filter it and make it your own. |
Ideal solution; upon a rich embed being added in the block editor (or being saved server-side) the thumbnail is fetched automatically and saved in the media library. If not available we automatically fallback on a (filterable) default one? Additional advantages:
|
If tapping the facade causes an |
@futtta that sounds like a pretty good approach. @westonruter - interesting - I see there's a lot of back and forth on that issue. |
a big difference between a facade-implementation and lazyloading is that the facade remains in place even when in view, the iframe is only loaded when a visitor wants to see the video by clicking/ tapping play. the impact on performance when the video is above-the-fold is obviously big but indeed comes with the double-tap disadvantage which I have not found a workaround for. |
The two tap problem still exists. But if that isn't a big deal to anyone, there are plenty of existing plugins implementing this already. Given the lack of activity here on this issue I am closing it as a maybelater. |
iFrames, especially those that load rich media formats like Youtube and Vimeo have generally been loaded and rendered on page load. This can often constitute a negative impact to page load speed as resources come from 3rd-party origins and can potentially pull in a lot of their own scripts.
The idea here would be to lazy-load rich media iFrames in order to improve page speed. One method of doing this, is known as the Facade method. Generally, this would apply to iFrames that are below the fold.
The facade method states that instead of loading the fully dynamic element, load a static element say an image instead, and then on a certain action, such as a mouseover or click: fetch, connect, render that 3rd-party resource.
There are number of libraries in the wild that already address this like:
https://github.com/paulirish/lite-youtube-embed
The idea, and logic behind this implementation is not overly complicated and could find a good home in the performance plugin or core as an opt-in feature / default. Based on my research, this could be an added feature to certain Gutenberg blocks which would aid in Frontend performance.
More information:
The text was updated successfully, but these errors were encountered: