简体   繁体   English

延迟加载:渐进式与按需加载

[英]lazy loading: progressive vs on-demand

This is a conceptual question.这是一个概念性的问题。 In my particular case, I am using slick.js to create an image carousel for a website.在我的特殊情况下,我使用slick.js为网站创建图像轮播。 Since these are high resolution photographs, I want to speed up the page load time by allowing the photographs to be loaded asynchronously instead of on page load.由于这些是高分辨率照片,我想通过允许异步加载照片而不是页面加载来加快页面加载时间。

When looking through the documentation for this library, I saw the settings available for the 'lazyLoad' property with little information as to what those settings mean in practice.在查看此库的文档时,我看到了可用于“lazyLoad”属性的设置,但几乎没有关于这些设置在实践中意味着什么的信息。

Essentially my question is, what is the difference between progressive and on-demand in the context of lazy loading.基本上我的问题是,在延迟加载的情况下,渐进式和按需之间有什么区别。

progressive : Loads the visible image as soon as the page is displayed and the other ones after everything else is loaded in the background (" loads the visible slides on init, and then progressively loads the rest of the slides on window.load(). ").渐进式:在页面显示后立即加载可见图像,并在后台加载其他所有内容后加载其他图像(“在 init 上加载可见幻灯片,然后在 window.load() 上逐步加载其余幻灯片)。 ”)。 Should be used if the other images will be used most (or all) of the times the page is displayed.如果其他图像将在页面显示的大部分(或全部)时间使用,则应使用。

on-demand : Loads the visible image as soon as the page is displayed and the other ones only when they're displayed. on-demand :在页面显示后立即加载可见图像,其他图像仅在显示时加载。 (" [...] loads slides on demand. When a slide becomes visible (or on the before slide callback) the load is fired. ") Should be used if the other images of the carousel are displayed very rarely. (“ [...] 按需加载幻灯片。当幻灯片变得可见时(或在之前的幻灯片回调中),加载被触发。 “)如果轮播的其他图像很少显示,则应使用。

Source: https://github.com/kenwheeler/slick/issues/35 , especially jasonday's comment from 5. Apr来源: https : //github.com/kenwheeler/slick/issues/35 ,尤其是 jasonday 5. 4 月的评论

It's worth mentioning that there is another value for the lazyLoad option in the source code, not documented though: 'anticipated'.值得一提的是,源代码中的 lazyLoad 选项还有另一个值,虽然没有记录:“预期”。 It was introduced in release 1.7.1它是在1.7.1 版中引入的

lazyLoad accepts 'ondemand', 'progressive', or 'anticipated' for lazy load technique.对于延迟加载技术,lazyLoad 接受“按需”、“渐进式”或“预期”。

'ondemand' will load the image as soon as you slide to it. 'ondemand'将在您滑动到该图像时立即加载该图像。

'progressive' loads one image after the other when the page loads. 'progressive'在页面加载时一个接一个地加载图像。

'anticipated' pre-loads the 1 next and 1 previous image. '预期'预加载 1 个下一个图像和 1 个上一个图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM