lazy-load-for-videos icon indicating copy to clipboard operation
lazy-load-for-videos copied to clipboard

Cache thumbnails for faster Lazy Loading

Open jeffmcneill opened this issue 9 years ago • 6 comments

Hello, it would be great to determine the thumbnail for each video (and embed the red youtube button, or other choice) one time only, and store that file locally. Then on next page load, if the file is detected (in some well-named/organized spot) it would not have to go and fetch a new thumbnail (which is generally not changed) on each page load. I realize there is a quality determination for the thumbnail, but that could still be supported by downloading several, and still run the test to select locally.

I'm willing to try and implement this if you could let me know how you would recommend doing this.

Thanks!

jeffmcneill avatar May 16 '16 07:05 jeffmcneill

Hi Jeff, that's a nice idea. I'm just not sure if that is worth the effort.

  1. Caching the red Youtube button might be handled by the web browser already [guess].
  2. Caching thumbnails is in so far not necessary because the majority of sites doesn't have the same video and thumbnails on more than one or two pages [hypothesis].

I won't spend more time thinking about this but feel free to make it working for your site and to send a pull request.

kevinweber avatar May 17 '16 01:05 kevinweber

Hi Kevin,

Ok, so I guess the name of the file being 0 is the big problem here? That's easy to fix, of course. Name the thumbnail the same as the video URI. Then it is unique across the web.

The reality is that this part of the lazy load isn't lazy at all, and it ends up taking time and resources which are unnecessary. Even the DNS query takes time. And time, my friend is money.

jeffmcneill avatar May 18 '16 14:05 jeffmcneill

Sorry, I don't get it. Please give a more specific example, provide a link to a page where I can see that behavior, and, ideally, submit a pull request.

kevinweber avatar May 19 '16 02:05 kevinweber

Bumping this as I've got the same issue here.

  1. Thumbnail images aren't lazy loaded, they're loaded as background-images on page load.
  2. Thumbnail images are hotlinked from a CDN with a low expiry time, which effects page speed scores.

Is it possible to 'capture' and modify the output of the plugin? If so I'd write my own functionst to modify the output myself.

SimeonGriggs avatar May 17 '19 13:05 SimeonGriggs

I plan to work on this in the next months by server-rendering the thumbnails instead of injecting it into the page using JavaScript.

kevinweber avatar Nov 06 '19 08:11 kevinweber

Sweet. We ended up forking the plugin to download a local copy (into /wp-content/uploads/llfvcache/ or something) of each thumbnail and serving from there.

SimeonGriggs avatar Nov 06 '19 09:11 SimeonGriggs