Page MenuHomePhabricator

Supporting NativeImageLazyLoading in Parsoid
Closed, ResolvedPublic

Description

T230897: Measure the impact of native image lazy loading on desktop added the "experimental" NativeImageLazyLoading configuration variable, and support for this in ThumbnailImage.php. This is used in [[Special:NewFiles]] (see https://en.wikipedia.org/wiki/Special:NewFiles ) but not otherwise; git log -S in the mediawiki-config repository doesn't turn up any indication that this was ever enabled in WMF production for any wiki, and the comments on T230897 seem to indicate that there were problems with users wanting to print an article w/ lazy images and the images not being present in the printout.

The loading attribute is implemented as part of the MediaTransformOutput options, but it doesn't look like Linker::getImageLinkMTOParams ever translates a wikitext file option string to this particular MTO option value. So this isn't exposed to wikitext at this time.

This is a placeholder bug for Parsoid support of the loading=lazy attribute on images. It is presumably extremely low priority as long as the NativeImageLazyLoading configuration isn't turned on in production. But if that experimental feature is ever picked up again, Parsoid will probably have to keep pace.

(Note there's an orthogonal issue with the use of loading=lazy for VE CE nodes (ve.ce.MWImageNode) to improve mobile performance, which Wikia is interested in exploring. That doesn't require any support from Parsoid, at least not at this time.)

Event Timeline

ssastry triaged this task as Medium priority.Dec 1 2022, 3:12 PM
cscott lowered the priority of this task from Medium to Lowest.Dec 1 2022, 3:12 PM

A small note that last week I added lazy loading to special pages that list files. This means that some of the core code for the lazy loading attribute is now actually in use (not gated behind the nativelazyloading config flag, which switches it on for ALL images indiscriminately). See also https://gerrit.wikimedia.org/r/c/mediawiki/core/+/883570/

Jdlrobson-WMF raised the priority of this task from Lowest to High.Apr 3 2026, 9:18 PM
Jdlrobson-WMF subscribed.

@cscott I still think it would be a good idea to do this, so that we can avoid parsing the entire HTML for mobile:

https://gerrit.wikimedia.org/g/mediawiki/extensions/MobileFrontend/+/fa0635a8ae58428a667fda0c421fd750fcc1bb2f/includes/Transforms/NativeLazyImageTransform.php#12

I think we can use T148047: Enable native image lazy loading on desktop to prioritize this work as it would likely reduce traffic to thumbnail servers.

Change #1314770 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/core@master] Export image attributes via imageinfo API and Parsoid DataAccess

https://gerrit.wikimedia.org/r/1314770

Change #1314807 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/services/parsoid@master] Support lazy image loading in Parsoid

https://gerrit.wikimedia.org/r/1314807

Change #1314770 merged by jenkins-bot:

[mediawiki/core@master] Export image attributes via imageinfo API and Parsoid DataAccess

https://gerrit.wikimedia.org/r/1314770

Change #1314807 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Support lazy image loading in Parsoid

https://gerrit.wikimedia.org/r/1314807

I think this can be resolved now?

Change #1323812 had a related patch set uploaded (by Isabelle Hurbain-Palatin; author: Isabelle Hurbain-Palatin):

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.24.0-a19

https://gerrit.wikimedia.org/r/1323812

Change #1323812 merged by jenkins-bot:

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.24.0-a19

https://gerrit.wikimedia.org/r/1323812

ABreault-WMF subscribed.

I think this can be resolved now?

Generally, as a team, we wait until our patches ride the train and are verified in production before closing

ABreault-WMF assigned this task to cscott.