Skip to content

Commit 440fde8

Browse files
authored
Suggest a rootMargin strategy for lazy-loaded elements
See #5408 (comment) Fixes #5408.
1 parent dc4af65 commit 440fde8

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

source

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6980,14 +6980,16 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
69806980

69816981
<li>
69826982
<p>The <var>options</var> is an <code>IntersectionObserverInit</code> dictionary with the
6983-
following dictionary members: «[ "<code data-x="">rootMargin</code>" → an
6984-
<span>implementation-defined</span> value ]»</p>
6985-
6986-
<p class="XXX">See <a
6987-
href="https://github.com/whatwg/html/issues/5408">issue #5408</a>.</p>
6983+
following dictionary members: «[ "<code data-x="">rootMargin</code>" → <span>lazy load root
6984+
margin</span> ]»</p>
69886985

69896986
<p class="note">This allows for fetching the image during scrolling, when it does not yet —
69906987
but is about to — intersect the viewport.</p>
6988+
6989+
<p class="XXX">The <span>lazy load root margin</span> suggestions imply dynamic changes to the
6990+
value, but the <code>IntersectionObserver</code> API does not support changing the root
6991+
margin. See issue <a
6992+
href="https://github.com/w3c/IntersectionObserver/issues/428">w3c/IntersectionObserver#428</a>.</p>
69916993
</li>
69926994
</ul>
69936995
</li>
@@ -7025,6 +7027,30 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
70257027
</li>
70267028
</ol>
70277029

7030+
<p>
7031+
<!--INSERT TRACKING-->
7032+
The <dfn>lazy load root margin</dfn> is an <span>implementation-defined</span> value, but with
7033+
the following suggestions to consider:</p>
7034+
7035+
<ul>
7036+
<li><p>Set a minimum value that most often results in the resources being loaded before they
7037+
intersect the viewport under normal usage patterns for the given device.</p></li>
7038+
7039+
<li><p>The typical scrolling speed: increase the value for devices with faster typical scrolling
7040+
speeds.</p></li>
7041+
7042+
<li><p>The current scrolling speed or momentum: the UA can attempt to predict where the scrolling
7043+
will likely stop, and adjust the value accordingly.</p></li>
7044+
7045+
<li><p>The network quality: increase the value for slow or high-latency connections.</p></li>
7046+
7047+
<li><p>User preferences can influence the value.</p></li>
7048+
</ul>
7049+
7050+
<p class="note">It is important <span class="no-backref" data-x="tracking vector">for
7051+
privacy</span> that the <span>lazy load root margin</span> not leak additional information. For
7052+
example, the typical scrolling speed on the current device could be imprecise so as to not
7053+
introduce a new fingerprinting vector.</p>
70287054

70297055
<h3 split-filename="common-dom-interfaces">Common DOM interfaces</h3>
70307056

0 commit comments

Comments
 (0)