Page MenuHomePhabricator

Enable native image lazy loading on desktop
Closed, ResolvedPublic

Description

Summary as of June 2026:

MobileFrontend shipped a JavaScript-based implementation for lazy loading images in 2016.

In 2019, the Performance Team implemented a native solution in MediaWiki core as a progressive enhancement (T230897). This feature flag remains disabled by default as of 2026 due to unresolved issues with printing (including save/export to PDF).

Upstream bugs with print mode:

In 2020, the JavaScript-based solution in MobileFrontend was rewritten using IntersectionObserver to avoid slow synchronous event handlers while scrolling (especially impactful on KaiOS). See T246838 and T246767.

In 2024, @TheDJ ported the native solution in MediaWiki core from legacy Parser to a Parsoid transform (limited to MobileFrontend and Parsoid-enabled wikis) as part of T230812. This is enabled in production e.g if you manually enable Parsoid on a page https://en.wikipedia.org/wiki/Canada?useformat=mobile&useparsoid=1.

Chrome fixed the print issue for desktop in 2022, but it appears to remain unresolved for Chrome Mobile (Android). It also remains unresolved in Safari, although for desktop Safari there's a workaround that TheDJ found (ref).

Fast-forward a few years and as of 2026, Parsoid is enabled on a lot of wikis. And while it is not yet enabled on enwiki as a whole, it is enabled for 100% of mobile web pageviews since April 2026 (T424880). As a result, native image lazy loading is enabled for all of these as well. But, we still haven't enabled it for desktop (i.e. the current task).

Note that the Parsoid implementation remains local to MobileFrontend and there are tasks to bring this into Parsoid itself and/or MediaWiki core, which is effectively a prerequisite for this task because enabilng $wgNativeImageLazyLoading would not ineffective for desktop on Parsoid-enabled wikis (T324158).

Original 2016 task description by @Jdlrobson:

After the success of https://blog.wikimedia.org/2016/09/19/mobile-web-improvements/ we should explore making the same changes in core (feature flagged of course) as the savings to be had are equally big (if not larger - there is an opportunity to save the cost of running Wikipedia if the bytes savings are significant).
Most of the code can easily be upstreamed with the exception of the MobileFormatter logic which would now be able to run in the parser.

Details

Related Changes in Gerrit:
SubjectAuthorRepoBranchLines +/-
Jdlrobsonmediawiki/extensions/MobileFrontendmaster+47 -1 K
Jdlrobsonmediawiki/coremaster+657 -651
Ladsgroup-claudemediawiki/extensions/PageImagesmaster+6 -18
Ladsgroup-claudemediawiki/extensions/TimedMediaHandlermaster+4 -12
Ladsgroup-claudemediawiki/extensions/ImageMapmaster+26 -77
Ladsgroup-claudemediawiki/extensions/TimedMediaHandlermaster+8 -0
Ladsgroup-claudemediawiki/extensions/Citemaster+11 -33
Ladsgroup-claudemediawiki/extensions/ImageMapmaster+51 -0
Ladsgroup-claudemediawiki/extensions/PageImagesmaster+12 -0
Ladsgroup-claudemediawiki/extensions/Citemaster+22 -0
Ladsgroupmediawiki/coremaster+5 -0
Jdlrobsonmediawiki/skins/MinervaNeuemaster+26 -88
Ladsgroupoperations/mediawiki-configmaster+1 -3
Ladsgroupoperations/mediawiki-configmaster+1 -0
Ladsgroupoperations/mediawiki-configmaster+5 -0
Isabelle Hurbain-Palatinmediawiki/vendormaster+5 K -5 K
Jdlrobsonmediawiki/extensions/MobileFrontendmaster+2 -54
C. Scott Ananianmediawiki/services/parsoidmaster+48 -31
Jdlrobsonmediawiki/coremaster+14 -1
Show related patches Customize query in gerrit

Related Objects

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

I was talking to @cscott about this today.
@CDanis enabling lazy loaded images on desktop in Parsoid would reduce requests for thumbnails across the site, reduces HTML processing time on mobile (which currently uses DOM parsing) and be an improvement for users so would likely also be popular with SRE. Currently the mobile version of Parsoid supports native lazy loading via MobileFrontend.

Untagging epic as using native lazy loading is a solved problem for mobile (and can be reused for desktop).

I was talking to @cscott about this today.
@CDanis enabling lazy loaded images on desktop in Parsoid would reduce requests for thumbnails across the site, reduces HTML processing time on mobile (which currently uses DOM parsing) and be an improvement for users so would likely also be popular with SRE. Currently the mobile version of Parsoid supports native lazy loading via MobileFrontend.

I'm not sure if lazy loading content when printing from Safari is fixed yet. I haven't tested it for a while (and the testcase has since disappeared).

Regardless, I don't think we should hold off on deploying Parsoid with lazy loading, even if it were to break Safari printing. The pageview share of Safari+print combined is small enough and people can use Chrome as a workaround when they do encounter this problem

An updated history:

History

MobileFrontend shipped a JavaScript-based implementation for lazy loading images in 2016.

In 2019, the Performance Team implemented a native solution in MediaWiki core as a progressive enhancement (T230897). This feature flag remains disabled by default as of 2026 due to unresolved issues with printing (including save/export to PDF).

Upstream bugs with print mode:

In 2020, the JavaScript-based solution in MobileFrontend was rewritten using IntersectionObserver to avoid slow synchronous event handlers while scrolling (especially impactful on KaiOS). See T246838 and T246767.

In 2024, @TheDJ ported the native solution in MediaWiki core from legacy Parser to a Parsoid transform (limited to MobileFrontend and Parsoid-enabled wikis) as part of T230812. This is enabled in production e.g if you manually enable Parsoid on a page https://en.wikipedia.org/wiki/Canada?useformat=mobile&useparsoid=1.

Chrome fixed the print issue for desktop in 2022, but it appears to remain unresolved for Chrome Mobile (Android). It also remains unresolved in Safari, although for desktop Safari there's a workaround that TheDJ found (ref).

Fast-forward a few years and as of 2026, Parsoid is enabled on a lot of wikis. And while it is not yet enabled on enwiki as a whole, it is enabled for 100% of mobile web pageviews since April 2026 (T424880). As a result, native image lazy loading is enabled for all of these as well. But, we still haven't enabled it for desktop (i.e. the current task).

Note that the Parsoid implementation remains local to MobileFrontend and there are tasks to bring this into Parsoid itself and/or MediaWiki core, which is effectively a prerequisite for this task because enabilng $wgNativeImageLazyLoading would not ineffective for desktop on Parsoid-enabled wikis (T324158).

Krinkle renamed this task from Desktop MediaWiki should be able to lazy load images to Enable native image lazy loading on desktop.Jun 25 2026, 2:52 AM
Krinkle updated the task description. (Show Details)

I think we should just add my hack to the site javascript, and add a link to each printed page pointing to the browsers’ bug tickets ;)

I think we should just add my hack to the site javascript, and add a link to each printed page pointing to the browsers bug tickets ;)

I agree ;) Jon is on it.

Change #1313908 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/MobileFrontend@master] beforeprint function has been upstreamed to core

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

Change #1313909 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/core@master] Move lazy loading print function from MobileFrontend to core.

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

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 #1313909 merged by jenkins-bot:

[mediawiki/core@master] Move lazy loading print function from MobileFrontend to core.

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

Change #1314807 merged by jenkins-bot:

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

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

Change #1313908 merged by jenkins-bot:

[mediawiki/extensions/MobileFrontend@master] beforeprint function has been upstreamed to core

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

Change #1323013 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/core@master] POC: Enable lazy loading on desktop

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

@Ladsgroup I think you should be unblocked now. I ran some tests on beta cluster and mobile is working as before and desktop appears to be working with the config change (https://fef3d41933.catalyst.wmcloud.org/wiki/Red-legged_seriema). Print is working as expected there.

Perhaps next week enable it on a group 1 or 0 wiki (eg. MediaWiki) for further testing?

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

Change #1313910 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/MobileFrontend@master] POC: Drop lazy image support in MobileFrontend

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

Change #1324369 had a related patch set uploaded (by Ladsgroup; author: Ladsgroup):

[operations/mediawiki-config@master] Enable desktop lazy loading on group0

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

Change #1324369 merged by jenkins-bot:

[operations/mediawiki-config@master] Enable desktop lazy loading on group0

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

Mentioned in SAL (#wikimedia-operations) [2026-08-11T17:45:31Z] <ladsgroup@deploy1003> Started scap sync-world: Backport for [[gerrit:1324369|Enable desktop lazy loading on group0 (T148047)]]

Mentioned in SAL (#wikimedia-operations) [2026-08-11T17:47:33Z] <ladsgroup@deploy1003> ladsgroup: Backport for [[gerrit:1324369|Enable desktop lazy loading on group0 (T148047)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2026-08-11T17:53:02Z] <ladsgroup@deploy1003> Finished scap sync-world: Backport for [[gerrit:1324369|Enable desktop lazy loading on group0 (T148047)]] (duration: 07m 31s)

Change #1325548 had a related patch set uploaded (by Ladsgroup; author: Ladsgroup):

[operations/mediawiki-config@master] Enable desktop lazy loading on group1

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

Change #1325548 merged by jenkins-bot:

[operations/mediawiki-config@master] Enable image lazy loading on desktop in group1

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

Mentioned in SAL (#wikimedia-operations) [2026-08-13T19:07:06Z] <ladsgroup@deploy1003> Started scap sync-world: Backport for [[gerrit:1325548|Enable image lazy loading on desktop in group1 (T148047)]]

Mentioned in SAL (#wikimedia-operations) [2026-08-13T19:10:16Z] <ladsgroup@deploy1003> ladsgroup: Backport for [[gerrit:1325548|Enable image lazy loading on desktop in group1 (T148047)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2026-08-13T19:14:49Z] <ladsgroup@deploy1003> Finished scap sync-world: Backport for [[gerrit:1325548|Enable image lazy loading on desktop in group1 (T148047)]] (duration: 07m 43s)

Change #1326227 had a related patch set uploaded (by Ladsgroup; author: Ladsgroup):

[operations/mediawiki-config@master] Enable desktop/native lazy loading everywhere

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

Change #1326227 merged by jenkins-bot:

[operations/mediawiki-config@master] Enable desktop/native lazy loading everywhere

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

Mentioned in SAL (#wikimedia-operations) [2026-08-17T09:56:54Z] <ladsgroup@deploy1003> Started scap sync-world: Backport for [[gerrit:1326227|Enable desktop/native lazy loading everywhere (T148047)]]

Mentioned in SAL (#wikimedia-operations) [2026-08-17T09:58:45Z] <ladsgroup@deploy1003> ladsgroup: Backport for [[gerrit:1326227|Enable desktop/native lazy loading everywhere (T148047)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2026-08-17T10:04:07Z] <ladsgroup@deploy1003> Finished scap sync-world: Backport for [[gerrit:1326227|Enable desktop/native lazy loading everywhere (T148047)]] (duration: 07m 13s)

Something along the lines of:

Images are now only load when they are viewed. Meaning if an image is at the bottom of an article and reader never scroll to that part of the page, it won't be loaded. This might affect metrics of some images.

Edit mercilessly

Change #1326313 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/skins/MinervaNeue@master] Remove MobileFrontend dependency in print for native lazy loaded images

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

I think gallery tag still needs to be dealt with: includes/Parser/Parser.php:5332'ish

Change #1326313 merged by jenkins-bot:

[mediawiki/skins/MinervaNeue@master] Remove MobileFrontend dependency in print for native lazy loaded images

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

Change #1326911 had a related patch set uploaded (by Ladsgroup; author: Ladsgroup):

[mediawiki/core@master] Parser: Add support for lazy loading in galleries

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

Test wiki created on Patch demo by Ladsgroup using patch(es) linked to this task:
https://8fbf45b2ab.catalyst.wmcloud.org/w/

Test wiki on Patch demo by Ladsgroup using patch(es) linked to this task was deleted:

https://8fbf45b2ab.catalyst.wmcloud.org/w/

I forgot I need to set the variable first. So the patch demo wouldn't work. But tested locally and works as expected.

I forgot I need to set the variable first. So the patch demo wouldn't work. But tested locally and works as expected.

So should the announcement still go out?

Also when you say:

Images are now "only load" when they are viewed. Meaning if an image is at the bottom of an article and reader never scroll to that part of the page, it won't be loaded. This might affect metrics of some images.

Is that a typo or that's how to put it technically?

I forgot I need to set the variable first. So the patch demo wouldn't work. But tested locally and works as expected.

So should the announcement still go out?

That was for an unrelated change (for third parties). It is deployed in our infra.

Also when you say:

Images are now "only load" when they are viewed. Meaning if an image is at the bottom of an article and reader never scroll to that part of the page, it won't be loaded. This might affect metrics of some images.

Is that a typo or that's how to put it technically?

That's how I put it technically but if someone else has a better way to describe it, by all means.

@Ladsgroup

To make it easier for translators, I have expanded it as follows, please check for accuracy:

"In order to improve page performance images now load when they are viewed. This means images lower down an article will not load if a reader never scrolls to that part of the page, which may affect some image-related metrics. The feature has been used on mobile through Parsoid and MobileFrontend, and work to enable native lazy loading for desktop is in progress."

All correct. Except this:

The feature has been used on mobile through Parsoid and MobileFrontend, and work to enable native lazy loading for desktop is in progress.

It has been deployed everywhere already. What we are working on is on default code for releases and it's unrelated to wikimedia or tech news readers.

Change #1326911 abandoned by Ladsgroup:

[mediawiki/core@master] Parser: Add support for lazy loading in galleries

Reason:

Not needed it seems

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

Change #1328599 had a related patch set uploaded (by Ladsgroup-claude; author: Ladsgroup-claude):

[mediawiki/extensions/Cite@master] Disable parser tests relying on images

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

Change #1328600 had a related patch set uploaded (by Ladsgroup-claude; author: Ladsgroup-claude):

[mediawiki/extensions/ImageMap@master] Disable parser tests relying on images

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

Change #1328602 had a related patch set uploaded (by Ladsgroup-claude; author: Ladsgroup-claude):

[mediawiki/extensions/PageImages@master] Disable parser tests relying on images

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

Change #1328603 had a related patch set uploaded (by Ladsgroup-claude; author: Ladsgroup-claude):

[mediawiki/extensions/TimedMediaHandler@master] Disable parser tests relying on images

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

Change #1328617 had a related patch set uploaded (by Ladsgroup-claude; author: Ladsgroup-claude):

[mediawiki/extensions/TimedMediaHandler@master] Update parser tests to use image native lazy loading

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

Change #1328618 had a related patch set uploaded (by Ladsgroup-claude; author: Ladsgroup-claude):

[mediawiki/extensions/PageImages@master] Update parser tests to use image native lazy loading

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

Change #1328619 had a related patch set uploaded (by Ladsgroup-claude; author: Ladsgroup-claude):

[mediawiki/extensions/ImageMap@master] Update parser tests to use image native lazy loading

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

Change #1328620 had a related patch set uploaded (by Ladsgroup-claude; author: Ladsgroup-claude):

[mediawiki/extensions/Cite@master] Update parser tests to use image native lazy loading

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

Change #1328599 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Disable parser tests relying on images

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

Change #1328600 merged by jenkins-bot:

[mediawiki/extensions/ImageMap@master] Disable parser tests relying on images

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

Change #1328602 merged by jenkins-bot:

[mediawiki/extensions/PageImages@master] Disable parser tests relying on images

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

Change #1328603 merged by jenkins-bot:

[mediawiki/extensions/TimedMediaHandler@master] Disable parser tests relying on images

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

Change #1323013 merged by jenkins-bot:

[mediawiki/core@master] Enable lazy loading on desktop

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

Change #1328620 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Update parser tests to use image native lazy loading

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

Change #1328619 merged by jenkins-bot:

[mediawiki/extensions/ImageMap@master] Update parser tests to use image native lazy loading

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

Change #1328618 merged by jenkins-bot:

[mediawiki/extensions/PageImages@master] Update parser tests to use image native lazy loading

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

Change #1328617 merged by jenkins-bot:

[mediawiki/extensions/TimedMediaHandler@master] Update parser tests to use image native lazy loading

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

Change #1313910 merged by jenkins-bot:

[mediawiki/extensions/MobileFrontend@master] Drop lazy image support in MobileFrontend

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