Felix Arntz
71140f327f
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 .
git-svn-id: https://develop.svn.wordpress.org/trunk@55847 602fd350-edb4-49c9-b593-d223f7449a82
2023-05-22 19:11:36 +00:00
..
2023-05-09 14:10:02 +00:00
2022-04-12 09:24:51 +00:00
2023-03-13 16:30:09 +00:00
2023-05-20 03:56:54 +00:00
2023-02-13 20:48:53 +00:00
2023-05-19 13:25:49 +00:00
2023-05-09 11:17:14 +00:00
2022-10-04 02:06:29 +00:00
2023-04-04 14:54:31 +00:00
2023-01-20 01:34:41 +00:00
2022-12-08 19:29:51 +00:00
2023-03-17 14:20:24 +00:00
2022-12-12 20:19:49 +00:00
2022-02-16 21:17:04 +00:00
2023-04-05 13:10:53 +00:00
2023-05-17 22:44:21 +00:00
2021-12-20 19:31:37 +00:00
2023-02-03 13:33:18 +00:00
2023-04-30 14:06:51 +00:00
2023-05-17 12:04:38 +00:00
2023-05-12 08:49:13 +00:00
2022-11-26 20:59:05 +00:00
2023-05-02 15:43:03 +00:00
2023-02-23 12:32:37 +00:00
2022-04-21 11:22:45 +00:00
2023-05-14 17:56:26 +00:00
2023-03-01 11:41:53 +00:00
2023-02-06 19:38:08 +00:00
2023-05-17 09:21:09 +00:00
2023-05-20 03:56:54 +00:00
2023-05-17 22:44:21 +00:00
2023-05-02 15:43:03 +00:00
2023-02-21 16:37:03 +00:00
2022-10-10 18:20:28 +00:00
2022-10-10 18:20:28 +00:00
2023-02-15 13:04:06 +00:00
2022-11-29 15:49:49 +00:00
2023-02-04 15:16:13 +00:00
2022-08-04 14:50:27 +00:00
2022-06-17 11:18:37 +00:00
2023-02-03 13:33:18 +00:00
2022-06-17 11:18:37 +00:00
2023-02-13 09:06:50 +00:00
2023-02-11 12:41:34 +00:00
2023-04-05 13:10:53 +00:00
2023-05-12 21:33:08 +00:00
2023-02-03 13:33:18 +00:00
2022-01-30 19:23:25 +00:00
2022-01-30 19:23:25 +00:00
2022-01-30 19:23:25 +00:00
2023-02-07 14:03:26 +00:00
2022-05-01 21:59:49 +00:00
2022-01-30 19:23:25 +00:00
2023-03-21 19:58:45 +00:00
2022-09-12 15:45:36 +00:00
2023-05-08 22:35:38 +00:00
2022-09-12 15:45:36 +00:00
2022-09-12 15:45:36 +00:00
2023-02-07 07:01:56 +00:00
2022-09-12 15:45:36 +00:00
2023-04-27 22:27:51 +00:00
2022-09-12 15:45:36 +00:00
2023-05-08 22:35:38 +00:00
2023-04-27 22:27:51 +00:00
2022-09-12 15:45:36 +00:00
2023-04-21 10:41:58 +00:00
2022-11-23 21:28:15 +00:00
2023-05-11 12:25:51 +00:00
2023-04-24 16:35:17 +00:00
2023-02-07 17:08:26 +00:00
2023-05-02 15:43:03 +00:00
2023-02-07 17:08:26 +00:00
2023-02-07 17:08:26 +00:00
2023-02-07 17:08:26 +00:00
2022-09-12 15:45:36 +00:00
2023-05-02 15:43:03 +00:00
2023-05-08 22:35:38 +00:00
2022-11-25 15:10:48 +00:00
2022-11-25 15:10:48 +00:00
2023-04-12 09:41:21 +00:00
2023-02-19 15:03:50 +00:00
2023-02-21 16:37:03 +00:00
2023-02-23 10:36:33 +00:00
2022-09-12 15:45:36 +00:00
2022-09-12 15:45:36 +00:00
2023-05-11 11:42:00 +00:00
2023-05-19 13:25:49 +00:00
2023-04-11 22:04:58 +00:00
2022-09-12 15:45:36 +00:00
2022-09-12 15:45:36 +00:00
2022-10-21 21:10:29 +00:00
2022-12-15 21:30:26 +00:00
2022-12-15 21:30:26 +00:00
2022-09-12 15:45:36 +00:00
2023-01-13 14:20:46 +00:00
2023-05-19 13:25:49 +00:00
2022-09-19 22:51:53 +00:00
2023-02-22 14:23:50 +00:00
2022-10-07 19:15:59 +00:00
2023-02-25 10:57:14 +00:00
2023-02-08 17:06:16 +00:00
2023-02-15 23:35:33 +00:00
2022-09-12 15:45:36 +00:00
2023-05-08 22:35:38 +00:00
2023-05-11 11:13:10 +00:00
2023-03-10 16:27:23 +00:00
2022-09-20 14:24:08 +00:00
2023-03-14 16:53:07 +00:00
2022-11-13 13:49:16 +00:00
2023-05-19 13:25:49 +00:00
2022-09-12 15:45:36 +00:00
2023-04-27 23:13:36 +00:00
2022-09-12 15:45:36 +00:00
2023-05-22 19:11:36 +00:00
2022-10-04 03:57:29 +00:00
2023-05-02 15:43:03 +00:00
2023-02-21 15:57:36 +00:00
2022-09-12 15:45:36 +00:00
2023-05-02 15:43:03 +00:00
2023-04-10 12:54:28 +00:00
2022-09-12 15:45:36 +00:00
2022-10-24 14:54:08 +00:00
2023-05-02 15:43:03 +00:00
2022-09-12 15:45:36 +00:00
2022-09-12 15:45:36 +00:00
2022-09-12 15:45:36 +00:00
2023-05-11 11:13:10 +00:00
2022-09-12 15:45:36 +00:00
2023-05-02 15:43:03 +00:00
2023-05-08 22:35:38 +00:00
2023-04-27 23:13:36 +00:00
2023-04-21 09:22:04 +00:00
2022-09-12 15:45:36 +00:00
2023-01-30 15:22:17 +00:00
2023-02-07 17:08:26 +00:00
2023-02-15 22:54:41 +00:00
2022-10-11 14:58:03 +00:00
2023-04-27 23:13:36 +00:00
2023-05-06 11:38:17 +00:00
2023-05-08 17:30:41 +00:00
2023-05-02 15:43:03 +00:00
2023-05-08 22:35:38 +00:00
2022-09-12 15:45:36 +00:00
2023-05-08 22:35:38 +00:00
2022-09-12 15:45:36 +00:00
2022-09-12 15:45:36 +00:00
2023-02-21 16:37:03 +00:00
2023-04-17 16:59:57 +00:00
2023-05-02 15:43:03 +00:00
2023-05-08 22:35:38 +00:00
2022-09-20 14:15:25 +00:00
2022-09-20 14:15:25 +00:00
2022-09-20 14:15:25 +00:00
2023-05-11 12:25:51 +00:00
2023-05-12 21:33:08 +00:00
2023-05-07 11:42:18 +00:00
2023-04-09 11:55:37 +00:00
2022-06-17 11:18:37 +00:00
2022-09-20 01:34:49 +00:00
2023-05-17 18:29:41 +00:00
2023-05-12 21:33:08 +00:00
2022-06-17 11:18:37 +00:00
2022-08-19 22:05:00 +00:00
2023-05-02 15:43:03 +00:00
2022-11-26 20:59:05 +00:00
2021-11-29 09:50:13 +00:00
2023-02-12 18:06:33 +00:00
2023-05-12 21:33:08 +00:00
2023-05-21 10:39:52 +00:00
2023-05-02 15:43:03 +00:00
2023-05-08 22:35:38 +00:00
2023-01-15 14:55:19 +00:00
2023-05-02 15:43:03 +00:00
2023-05-03 18:46:44 +00:00
2023-04-27 23:13:36 +00:00
2023-04-04 14:54:31 +00:00
2023-05-17 22:44:21 +00:00
2023-05-16 14:16:39 +00:00
2023-05-10 17:34:13 +00:00
2023-04-24 13:51:15 +00:00
2023-05-19 13:25:49 +00:00
2023-05-22 19:11:36 +00:00
2023-05-19 12:44:54 +00:00
2023-04-24 13:51:15 +00:00
2022-07-14 13:33:12 +00:00
2023-02-24 01:21:54 +00:00
2022-12-09 11:52:58 +00:00
2023-04-18 11:48:46 +00:00
2023-02-23 10:36:33 +00:00
2023-05-02 11:24:52 +00:00
2023-05-11 11:13:10 +00:00
2023-02-16 00:02:21 +00:00
2023-02-15 22:54:41 +00:00
2023-05-19 13:25:49 +00:00
2023-05-02 15:43:03 +00:00
2023-05-12 21:33:08 +00:00
2023-02-21 16:37:03 +00:00
2023-05-02 15:43:03 +00:00
2023-05-17 18:29:41 +00:00
2023-05-22 10:01:07 +00:00
2023-03-10 16:27:23 +00:00
2023-05-02 15:43:03 +00:00
2023-02-22 20:47:38 +00:00
2023-05-02 15:43:03 +00:00
2022-04-06 15:31:23 +00:00
2023-04-10 19:29:15 +00:00
2023-05-17 22:44:21 +00:00
2023-05-03 18:46:44 +00:00
2023-05-17 12:04:38 +00:00
2023-05-16 12:29:34 +00:00
2021-12-10 20:28:27 +00:00
2023-04-10 12:54:28 +00:00
2022-09-21 11:41:44 +00:00
2023-02-19 15:03:50 +00:00
2023-02-22 15:58:56 +00:00
2023-05-02 15:43:03 +00:00
2023-05-04 02:34:58 +00:00
2023-05-11 11:13:10 +00:00
2023-02-23 10:36:33 +00:00
2023-03-09 21:36:06 +00:00
2023-02-23 11:04:40 +00:00
2022-07-21 22:43:24 +00:00