Felix Arntz
c6f9238b77
Media: Conditionally skip lazy-loading on images before the loop to improve LCP performance.
...
When the logic to exclude images that likely appear above the fold from being lazy-loaded was introduced in WordPress 5.9, initially only images that appear within the main query loop were being considered. However, there is a good chance that images above the fold are rendered before the loop starts, for example in the header template part.
It is particularly common for a theme to display the featured image for a single post in the header. Based on HTTP Archive data from February 2023, the majority of LCP images that are still being lazy-loaded on WordPress sites use the `wp-post-image` class, i.e. are featured images.
This changeset enhances the logic in `wp_get_loading_attr_default()` to not lazy-load images that appear within or after the header template part and before the query loop, using a new `WP_Query::$before_loop` property.
For block themes, this was for the most part already addressed in [55318], however this enhancement implements the solution in a more generally applicable way that brings the improvement to classic themes as well.
Props thekt12, flixos90, spacedmonkey, costdev, zunaid321, mukesh27.
Fixes #58211 .
See #53675 , #56930 .
Built from https://develop.svn.wordpress.org/trunk@55847
git-svn-id: http://core.svn.wordpress.org/trunk@55359 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-22 19:13:21 +00:00
..
2023-05-09 14:13:25 +00:00
2023-03-13 16:32:20 +00:00
2023-05-20 03:58:47 +00:00
2023-03-21 12:43:46 +00:00
2023-05-19 13:27:20 +00:00
2023-05-09 11:19:21 +00:00
2022-10-04 02:08:11 +00:00
2023-04-04 14:56:22 +00:00
2023-01-20 01:36:10 +00:00
2023-05-20 10:19:23 +00:00
2022-12-08 19:31:17 +00:00
2023-03-17 14:22:22 +00:00
2022-12-12 20:21:12 +00:00
2023-04-05 13:12:26 +00:00
2023-05-17 22:46:24 +00:00
2023-02-03 13:35:20 +00:00
2023-04-30 14:08:23 +00:00
2023-05-17 12:06:19 +00:00
2023-05-12 08:51:22 +00:00
2022-11-26 21:01:17 +00:00
2023-05-02 15:45:22 +00:00
2023-02-23 12:34:18 +00:00
2023-05-14 17:58:24 +00:00
2023-03-01 11:43:20 +00:00
2023-02-06 19:40:16 +00:00
2023-05-17 09:23:24 +00:00
2023-05-20 03:58:47 +00:00
2023-05-17 22:46:24 +00:00
2023-05-02 15:45:22 +00:00
2023-02-21 16:39:19 +00:00
2022-10-10 18:22:11 +00:00
2022-10-10 18:22:11 +00:00
2023-02-15 13:06:21 +00:00
2022-11-29 15:51:14 +00:00
2023-02-04 15:18:16 +00:00
2023-02-03 13:35:20 +00:00
2023-02-13 09:08:23 +00:00
2023-02-11 12:43:22 +00:00
2023-04-05 13:12:26 +00:00
2023-05-12 21:35:21 +00:00
2023-02-03 13:35:20 +00:00
2023-02-07 14:05:20 +00:00
2023-03-21 20:00:19 +00:00
2022-09-12 15:47:14 +00:00
2023-05-08 22:37:24 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2023-02-07 07:04:52 +00:00
2022-09-12 15:47:14 +00:00
2023-04-27 22:29:18 +00:00
2022-09-12 15:47:14 +00:00
2023-05-08 22:37:24 +00:00
2023-04-27 22:29:18 +00:00
2022-09-12 15:47:14 +00:00
2023-04-21 10:43:25 +00:00
2022-11-23 21:30:13 +00:00
2023-05-11 12:27:22 +00:00
2023-04-24 16:37:22 +00:00
2023-02-07 17:10:21 +00:00
2023-05-02 15:45:22 +00:00
2023-02-07 17:10:21 +00:00
2023-02-07 17:10:21 +00:00
2023-02-07 17:10:21 +00:00
2022-09-12 15:47:14 +00:00
2023-05-02 15:45:22 +00:00
2023-05-08 22:37:24 +00:00
2022-11-25 15:12:16 +00:00
2022-11-25 15:12:16 +00:00
2023-04-12 09:43:21 +00:00
2023-02-19 15:05:22 +00:00
2023-02-21 16:39:19 +00:00
2023-02-23 10:38:21 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2023-05-11 11:43:21 +00:00
2023-05-19 13:27:20 +00:00
2023-04-11 22:06:22 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-10-21 21:12:14 +00:00
2022-12-15 21:32:17 +00:00
2022-12-15 21:32:17 +00:00
2022-09-12 15:47:14 +00:00
2023-01-13 14:22:12 +00:00
2023-05-19 13:27:20 +00:00
2022-09-19 22:53:10 +00:00
2023-02-22 14:25:25 +00:00
2022-10-07 19:17:12 +00:00
2023-02-25 10:59:22 +00:00
2023-02-08 17:08:21 +00:00
2023-02-15 23:37:17 +00:00
2022-09-12 15:47:14 +00:00
2023-05-08 22:37:24 +00:00
2023-05-11 11:15:24 +00:00
2023-03-10 16:30:03 +00:00
2022-09-20 14:26:10 +00:00
2023-03-14 16:55:19 +00:00
2022-11-13 13:51:20 +00:00
2023-05-19 13:27:20 +00:00
2022-09-12 15:47:14 +00:00
2023-04-27 23:15:17 +00:00
2022-09-12 15:47:14 +00:00
2023-05-22 19:13:21 +00:00
2022-10-04 03:59:13 +00:00
2023-05-02 15:45:22 +00:00
2023-02-21 15:59:18 +00:00
2022-09-12 15:47:14 +00:00
2023-05-02 15:45:22 +00:00
2023-04-10 12:56:21 +00:00
2022-09-12 15:47:14 +00:00
2022-10-24 14:56:16 +00:00
2023-05-02 15:45:22 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2023-05-11 11:15:24 +00:00
2022-09-12 15:47:14 +00:00
2023-05-02 15:45:22 +00:00
2023-05-08 22:37:24 +00:00
2023-04-27 23:15:17 +00:00
2023-04-21 09:24:22 +00:00
2022-09-12 15:47:14 +00:00
2023-01-30 15:24:13 +00:00
2023-02-07 17:10:21 +00:00
2023-02-15 22:56:20 +00:00
2022-10-11 15:00:12 +00:00
2023-04-27 23:15:17 +00:00
2023-05-06 11:40:24 +00:00
2023-05-08 17:32:24 +00:00
2023-05-02 15:45:22 +00:00
2023-05-08 22:37:24 +00:00
2022-09-12 15:47:14 +00:00
2023-05-08 22:37:24 +00:00
2022-09-12 15:47:14 +00:00
2022-09-12 15:47:14 +00:00
2023-02-21 16:39:19 +00:00
2023-04-17 17:01:24 +00:00
2023-05-02 15:45:22 +00:00
2023-05-08 22:37:24 +00:00
2022-09-20 14:17:12 +00:00
2022-09-20 14:17:12 +00:00
2022-09-20 14:17:12 +00:00
2023-05-11 12:27:22 +00:00
2023-05-12 21:35:21 +00:00
2023-05-07 11:44:21 +00:00
2023-04-09 11:57:22 +00:00
2022-09-20 01:36:09 +00:00
2023-05-17 18:31:24 +00:00
2023-05-12 21:35:21 +00:00
2023-05-02 15:45:22 +00:00
2022-11-26 21:01:17 +00:00
2023-02-12 18:08:21 +00:00
2023-05-12 21:35:21 +00:00
2023-05-21 10:41:22 +00:00
2023-05-02 15:45:22 +00:00
2023-05-08 22:37:24 +00:00
2023-01-15 14:57:13 +00:00
2023-05-02 15:45:22 +00:00
2023-05-03 18:48:22 +00:00
2023-04-27 23:15:17 +00:00
2023-04-04 14:56:22 +00:00
2023-05-17 22:46:24 +00:00
2023-05-16 14:18:20 +00:00
2023-05-10 17:36:21 +00:00
2023-04-24 13:53:22 +00:00
2023-05-19 13:27:20 +00:00
2023-05-22 19:13:21 +00:00
2023-05-19 12:46:24 +00:00
2023-04-24 13:53:22 +00:00
2023-02-24 01:23:20 +00:00
2022-12-09 11:54:13 +00:00
2023-04-18 11:50:27 +00:00
2023-02-23 10:38:21 +00:00
2023-05-02 11:26:24 +00:00
2023-05-11 11:15:24 +00:00
2023-02-16 00:04:21 +00:00
2023-02-15 22:56:20 +00:00
2023-05-19 13:27:20 +00:00
2023-05-02 15:45:22 +00:00
2023-05-12 21:35:21 +00:00
2023-02-21 16:39:19 +00:00
2023-05-02 15:45:22 +00:00
2023-05-17 18:31:24 +00:00
2023-05-22 10:03:22 +00:00
2023-03-10 16:30:03 +00:00
2023-05-02 15:45:22 +00:00
2023-02-22 20:49:20 +00:00
2023-05-02 15:45:22 +00:00
2023-04-10 19:31:18 +00:00
2023-05-17 22:46:24 +00:00
2023-05-03 18:48:22 +00:00
2023-05-17 12:06:19 +00:00
2023-05-16 12:31:21 +00:00
2023-04-10 12:56:21 +00:00
2022-09-21 11:43:13 +00:00
2023-02-19 15:05:22 +00:00
2023-02-22 16:00:21 +00:00
2023-05-02 15:45:22 +00:00
2023-05-04 02:36:23 +00:00
2023-05-11 11:15:24 +00:00
2023-02-23 10:38:21 +00:00
2023-05-22 19:13:21 +00:00
2023-02-23 11:06:19 +00:00