diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index c0669dab7a99..20fc10cd5536 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -1629,7 +1629,7 @@ # # See https://github.com/whatwg/html/pull/3752 - name: dom.image-lazy-loading.enabled - type: bool + type: RelaxedAtomicBool value: false mirror: always diff --git a/parser/html/nsHtml5TreeBuilderCppSupplement.h b/parser/html/nsHtml5TreeBuilderCppSupplement.h index b99b969f88fe..6db63a0d8730 100644 --- a/parser/html/nsHtml5TreeBuilderCppSupplement.h +++ b/parser/html/nsHtml5TreeBuilderCppSupplement.h @@ -7,6 +7,7 @@ #include "nsError.h" #include "mozilla/CheckedInt.h" #include "mozilla/Likely.h" +#include "mozilla/StaticPrefs_dom.h" #include "mozilla/StaticPrefs_network.h" #include "mozilla/UniquePtr.h" @@ -170,18 +171,23 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement( switch (aNamespace) { case kNameSpaceID_XHTML: if (nsGkAtoms::img == aName) { - nsHtml5String url = - aAttributes->getValue(nsHtml5AttributeName::ATTR_SRC); - nsHtml5String srcset = - aAttributes->getValue(nsHtml5AttributeName::ATTR_SRCSET); - nsHtml5String crossOrigin = - aAttributes->getValue(nsHtml5AttributeName::ATTR_CROSSORIGIN); - nsHtml5String referrerPolicy = - aAttributes->getValue(nsHtml5AttributeName::ATTR_REFERRERPOLICY); - nsHtml5String sizes = - aAttributes->getValue(nsHtml5AttributeName::ATTR_SIZES); - mSpeculativeLoadQueue.AppendElement()->InitImage( - url, crossOrigin, referrerPolicy, srcset, sizes); + nsHtml5String loading = + aAttributes->getValue(nsHtml5AttributeName::ATTR_LOADING); + if (!StaticPrefs::dom_image_lazy_loading_enabled() || + !loading.LowerCaseEqualsASCII("lazy")) { + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_SRC); + nsHtml5String srcset = + aAttributes->getValue(nsHtml5AttributeName::ATTR_SRCSET); + nsHtml5String crossOrigin = + aAttributes->getValue(nsHtml5AttributeName::ATTR_CROSSORIGIN); + nsHtml5String referrerPolicy = aAttributes->getValue( + nsHtml5AttributeName::ATTR_REFERRERPOLICY); + nsHtml5String sizes = + aAttributes->getValue(nsHtml5AttributeName::ATTR_SIZES); + mSpeculativeLoadQueue.AppendElement()->InitImage( + url, crossOrigin, referrerPolicy, srcset, sizes); + } } else if (nsGkAtoms::source == aName) { nsHtml5String srcset = aAttributes->getValue(nsHtml5AttributeName::ATTR_SRCSET);