Web compat: Navigating a lazy-loading iframe with location.replace #10213
Labels
compat
Standard is not web compatible or proprietary feature needs standardizing
interop
Implementations are not interoperable with each other
topic: navigation
What is the issue with the HTML Standard?
See https://bugzilla.mozilla.org/show_bug.cgi?id=1882670
Some pages use the lazysizes library with lazy-loaded iframes with the intended source in a
data-src
attribute and a placeholder in thesrc
attribute, as documented in https://github.com/aFarkas/lazysizes?tab=readme-ov-file#how-to but also specifyloading="lazy"
.The code at https://github.com/aFarkas/lazysizes/blob/gh-pages/src/lazysizes-core.js#L484 invokes
location.replace()
before the iframe has lazily loaded, which navigates the iframe. When the browser determines that the iframe is sufficiently in view, it invokes the lazy load resumption steps which navigates to the URL in thesrc
attribute (except Chrome doesn't, it seems).Demo: https://software.hixie.ch/utilities/js/live-dom-viewer/saved/12473
I think lazySizes could remove
loading
attributes on iframes with alazyload
class so that the placeholdersrc
is loaded eagerly and to avoid timing issues with which navigation is the last one, in current Firefox and Safari. Or at least removeloading
attribute right beforelocation.replace
. (Filed aFarkas/lazysizes#994) cc @aFarkasBut also I think the spec can be changed such that navigating an iframe where will lazy load element steps is true will set the iframe's lazy load resumption steps to null. If script invokes a navigation, it seems reasonable to expect that the script-initiated navigation isn't overridden by lazy-loading the
src
. Does this match what is implemented in Chromium? cc @domfarolinocc @rwlbuis @smfr
The text was updated successfully, but these errors were encountered: