From f0e365c7b6d7867da0394b886288c1e654a99b0e Mon Sep 17 00:00:00 2001 From: tcaptan-cr <105748547+tcaptan-cr@users.noreply.github.com> Date: Thu, 16 Nov 2023 11:05:07 -0800 Subject: [PATCH] Use scrollMargin for lazy load intersection observer Currently the lazy load intersection observer is set up using a rootMargin. This does not work well for pages that use images in CSS scrollers, like carousels, causing the images to load too late, when they become visible and the intersection with the root is detected. To work around this issue some developers are choosing to not use lazy loading, thus increasing the overall bandwidth usage for their sites. Using scrollMargin for the lazy load intersection observer will allow lazy loading images to load when they are near the viewport as expected. --- source | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/source b/source index 61e7d1cd9ef..760de2984fc 100644 --- a/source +++ b/source @@ -7629,14 +7629,14 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • The options is an IntersectionObserverInit dictionary with the - following dictionary members: «[ "rootMargin" → lazy load root + following dictionary members: «[ "scrollMargin" → lazy load scroll margin

    This allows for fetching the image during scrolling, when it does not yet — but is about to — intersect the viewport.

    -

    The lazy load root margin suggestions imply dynamic changes to the - value, but the IntersectionObserver API does not support changing the root +

    The lazy load scroll margin suggestions imply dynamic changes to the + value, but the IntersectionObserver API does not support changing the scroll margin. See issue w3c/IntersectionObserver#428.

  • @@ -7678,8 +7678,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

    - The lazy load root margin is an implementation-defined value, but with - the following suggestions to consider:

    + The lazy load scroll margin is an + implementation-defined value, but with the following suggestions to consider:

    It is important for privacy that the - lazy load root margin not leak additional information. For example, the typical + lazy load scroll margin not leak additional information. For example, the typical scrolling speed on the current device could be imprecise so as to not introduce a new fingerprinting vector.

    @@ -141466,6 +141466,7 @@ INSERT INTERFACES HERE Tony Ross, Tooru Fujisawa, Toru Kobayashi, + Traian Captan, Travis Leithead, Trevor Rowbotham, Trevor Saunders,