Javascript 延迟加载:渐进式与按需加载
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25726554/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
lazy loading: progressive vs on-demand
提问by Caleb Faruki
This is a conceptual question. In my particular case, I am using slick.jsto create an image carousel for a website. 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.
这是一个概念性的问题。在我的特殊情况下,我使用slick.js为网站创建图像轮播。由于这些是高分辨率照片,我想通过允许异步加载照片而不是页面加载来加快页面加载时间。
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.
基本上我的问题是,在延迟加载的情况下,渐进式和按需之间有什么区别。
回答by Reeno
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()."). Should be used if the other images will be used most (or all) of the times the page is displayed.
渐进式:在页面显示后立即加载可见图像,并在后台加载其他所有内容后加载其他图像(“在初始化时加载可见幻灯片,然后在 window.load() 上逐步加载其余幻灯片)。”)。如果其他图像将在页面显示的大部分(或全部)时间使用,则应使用。
on-demand: Loads the visible image as soon as the page is displayed and the other ones only when they're displayed. ("[...] 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.
on-demand:在页面显示后立即加载可见图像,其他图像仅在显示时加载。(“ [...] 按需加载幻灯片。当幻灯片变得可见时(或在之前的幻灯片回调中),加载被触发。“)如果轮播的其他图像很少显示,则应使用。
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 月的评论

