Make WordPress Core

Opened 12 months ago

Closed 11 months ago

Last modified 9 months ago

#58213 closed enhancement (fixed)

Increase default for `wp_omit_loading_attr_threshold` to 3

Reported by: flixos90's profile flixos90 Owned by: flixos90's profile flixos90
Milestone: 6.3 Priority: high
Severity: normal Version:
Component: Media Keywords: has-patch, has-unit-tests, has-dev-note
Focuses: performance Cc:

Description

The current default threshold for how many content images to skip lazy-loading on (which is just 1) has proven to be too strict: Many sites have more than 1 large image and potential LCP candidate visible above the fold, and due to the very conservative threshold here, those sites may end up lazy-loading their LCP image which negatively affects load time performance.

Based on HTTP Archive data queried to get a better idea of this (see attached screenshot), a reasonable default value for the filter would be 3. >70% of sites have up to 3 equal-sized images in the initial viewport, each of which could be the LCP image and therefore should not be lazy-loaded. Sites that have fewer than 3 images above the fold will not see a negative performance impact, they will only lose out on 1-2 images that may otherwise have been lazy-loaded to be loaded immediately, which is an acceptable tradeoff to get faster overall load time performance.

While we could of course increase the default to even a higher number, the % of sites that use a specific number greater than 3 is much lower, e.g. to cover 80% of sites in total, the default threshold would need to be set to 8, which is excessive and would reduce the lazy-loading benefits too much for the majority of sites.

Attachments (1)

http-archive-number-of-lcp-candidates.png (67.0 KB) - added by flixos90 12 months ago.
HTTP Archive data screenshot for how many sites have a given number of LCP candidates

Download all attachments as: .zip

Change History (11)

@flixos90
12 months ago

HTTP Archive data screenshot for how many sites have a given number of LCP candidates

#1 @flixos90
12 months ago

  • Priority changed from normal to high

Addressing the remaining lazy-loading related performance issues is a high priority for the performance team for the 6.3 cycle.

This ticket was mentioned in Slack in #core-media by antpb. View the logs.


12 months ago

This ticket was mentioned in PR #4428 on WordPress/wordpress-develop by kt-12.


12 months ago
#3

  • Keywords has-patch has-unit-tests added; needs-patch needs-unit-tests removed

Trac ticket: https://core.trac.wordpress.org/ticket/58213

Increase wp_omit_loading_attr_threshold threshold to 3

kt-12 commented on PR #4428:


11 months ago
#4

@felixarntz This is good for review. I have fixed both the test error (here) by using wp_omit_loading_attr_threshold filter.

#5 @spacedmonkey
11 months ago

  • Keywords commit added
  • Owner set to flixos90
  • Status changed from new to assigned

Marking as ready to commit and assigning to @flixos90 to commit.

#6 @flixos90
11 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 55816:

Media: Increase default for wp_omit_loading_attr_threshold to 3.

The previous default threshold for how many content images to skip lazy-loading on (which was just 1) has proven to be too strict: HTTP Archive data shows that >70% of sites have up to 3 equal-sized images in the initial viewport, each of which could be the LCP image and therefore should not be lazy-loaded. Lazy-loading too many images has adverse effects on load time performance, while increasing the default threshold will not negatively affect load time performance even for sites where a threshold of 1 would be the perfect choice.

The change of default value in this changeset will improve performance for more WordPress sites out of the box. The wp_omit_loading_attr_threshold filter can still be used to customize and fine tune the value where needed.

Props thekt12, spacedmonkey, westonruter, flixos90.
Fixes #58213.

#8 @flixos90
11 months ago

  • Keywords needs-dev-note added; commit removed

#10 @flixos90
9 months ago

  • Keywords needs-dev-note removed
Note: See TracTickets for help on using tickets.