I've heard this mentioned but never explicitly written down as a requirement.
Lazy loading an image that appears above the fold is wasteful and we should avoid as much as possible.
It was suggested we should look to lazy load images only if they appear in a section greater than 0 (the lead section)
Description
Details
Event Timeline
I'm landing this in sprint 67, but we'll be discussing next steps on lazy loading stage gating.
Also think this is important so that the look-ahead-parser can pick up the most important images and start download as fast as possible. Would love to have a metrics when the first image is displayed for the user.
This proved to be a pain as I couldn't simply traverse upwards and look for the lead section (the section wrapping happens on getText function).
An alternative approach could involve adding data-section-ids to all images via a parser hook to avoid this scanning and turn this into a simple getAttribute lookup operation for section id.
Change 274786 had a related patch set uploaded (by Jdlrobson):
Only lazy load images outside the lead section
I don't agree with the approach in the patch. It seems very wasteful and inefficient (recursive traversal of siblings up a tree for each image node), I'd rather we do it the correct way if we have to do this feature right now.
As I wrote here https://phabricator.wikimedia.org/T124770#2011918
I'd suggest changing sectioning to be dom based like in @phuedx's fork (integrate his changes), move it to happen before the transformations/filtering, and applying the transformations/filtering to the intended sections.
Happy to take over if you agree @Jdlrobson. Going to put it in -1 for discussing.
I'm fine with this... given we are now relying more on the MobileFormatter. It will also reduce bugs related to this. Feel free to propose an alternative patch.
Change 275878 had a related patch set uploaded (by Jhernandez):
Perform sectioning in MobileFormater before filtering
Change 275879 had a related patch set uploaded (by Jhernandez):
MobileFormatter: Move lazyLoadImages rewrite to be per-section
Change 275880 had a related patch set uploaded (by Jhernandez):
Only lazy load images after the first section
Change 274786 abandoned by Jdlrobson:
Only lazy load images outside the lead section
Reason:
Heading in favour of Joakino's solution
Change 275879 merged by jenkins-bot:
MobileFormatter: Move lazyLoadImages rewrite to be per-section
Deployed and signed off on http://reading-web-staging.wmflabs.org/wiki/Doctor_Who
First image is in HTML rest are not and are lazy loaded