Skip to content
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

Remove preload resource hint #102

Closed
kevinfarrugia opened this issue Nov 2, 2021 · 2 comments
Closed

Remove preload resource hint #102

kevinfarrugia opened this issue Nov 2, 2021 · 2 comments

Comments

@kevinfarrugia
Copy link

Currently there is a preload hint for the poster image, however I would argue that we cannot assume that the poster image should always be preloaded (the user may have more critical resources or the video is outside of the initial viewport. Also, since the rel="preload" element is being added through JavaScript, I do not think it is really being preloaded and the gains are almost nil. And if a user wants to make use of preload directly in the HTML, they will end up with duplicate link elements for the poster image (probably not a big deal).

Where we are currently preloading:

if (!this.style.backgroundImage) {
  this.posterUrl = `https://i.ytimg.com/vi/${this.videoId}/hqdefault.jpg`;
  // Warm the connection for the poster image
  LiteYTEmbed.addPrefetch('preload', this.posterUrl, 'image');

  this.style.backgroundImage = `url("${this.posterUrl}")`;
}
@paulirish
Copy link
Owner

Currently there is a preload hint for the poster image, however I would argue that we cannot assume that the poster image should always be preloaded (the user may have more critical resources or the video is outside of the initial viewport.

Yes, this is entirely possible. The fact that this preload is added through JS likely addresses most of the problem though, since that means this image preload is definitely last in the queue behind any preloads found in the real HTML.

And since it's a as=image, it's got a "low" network priority, so the changes of slowing down something important is mostly addressed.

Also, since the rel="preload" element is being added through JavaScript, I do not think it is really being preloaded and the gains are almost nil.

hmm well yes this is probably true. :)

And if a user wants to make use of preload directly in the HTML, they will end up with duplicate link elements for the poster image (probably not a big deal).

agree on both counts. it'll just find the resource in the cache and all is bueno.


all in all, i think this particular preload has very little value, but i also don't think its causing much harm.

@paulirish
Copy link
Owner

all in all, i think this particular preload has very little value, but i also don't think its causing much harm.

ok 20 minutes later and digging into #103 i am convinced. :p

closed by #106

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants