-
Notifications
You must be signed in to change notification settings - Fork 143
Compute responsive sizes attribute based on the width from the boundingClientRect in captured URL Metrics
#1840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
4d39880
7b620c2
f964684
f606dac
a9fba2c
74c2ce6
df0c9e2
cdda7c3
6045b18
93961fa
eca53e6
d2b9a5c
4d0251a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7,7 +7,7 @@ License: GPLv2 or later | |||||
| License URI: https://www.gnu.org/licenses/gpl-2.0.html | ||||||
| Tags: performance, optimization, image, lcp, lazy-load | ||||||
|
|
||||||
| Prioritizes the loading of images and videos based on how visible they are to actual visitors; adds fetchpriority and applies lazy loading. | ||||||
| Prioritizes the loading of images and videos based on how they appear to actual visitors: adds fetchpriority, preloads, lazy-loads, and sets sizes. | ||||||
|
|
||||||
| == Description == | ||||||
|
|
||||||
|
|
@@ -27,7 +27,9 @@ The current optimizations include: | |||||
| 1. Apply lazy loading to `IMG` tags based on whether they appear in any breakpoint’s initial viewport. | ||||||
| 2. Implement lazy loading of CSS background images added via inline `style` attributes. | ||||||
| 3. Lazy-load `VIDEO` tags by setting the appropriate attributes based on whether they appear in the initial viewport. If a `VIDEO` is the LCP element, it gets `preload=auto`; if it is in an initial viewport, the `preload=metadata` default is left; if it is not in an initial viewport, it gets `preload=none`. Lazy-loaded videos also get initial `preload`, `autoplay`, and `poster` attributes restored when the `VIDEO` is going to enter the viewport. | ||||||
| 5. Ensure that [`sizes=auto`](https://make.wordpress.org/core/2024/10/18/auto-sizes-for-lazy-loaded-images-in-wordpress-6-7/) is added to all lazy-loaded `IMG` elements. | ||||||
| 5. Responsive image sizes: | ||||||
| 1. Ensure [`sizes=auto`](https://make.wordpress.org/core/2024/10/18/auto-sizes-for-lazy-loaded-images-in-wordpress-6-7/) is added to all lazy-loaded `IMG` elements. | ||||||
|
||||||
| 1. Ensure [`sizes=auto`](https://make.wordpress.org/core/2024/10/18/auto-sizes-for-lazy-loaded-images-in-wordpress-6-7/) is added to all lazy-loaded `IMG` elements. | |
| 1. Ensure [`sizes=auto`](https://make.wordpress.org/core/2024/10/18/auto-sizes-for-lazy-loaded-images-in-wordpress-6-7/) is set on `IMG` tags after setting correct lazy-loading (above). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, plus moving it to #2 in the list as mentioned :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes! Done: 4d0251a
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,7 @@ | ||
| <?php | ||
| return static function ( Test_Image_Prioritizer_Helper $test_case ): void { | ||
| $slug = od_get_url_metrics_slug( od_get_normalized_query_vars() ); | ||
| $sample_size = od_get_url_metrics_breakpoint_sample_size(); | ||
| $outside_viewport_rect = array_merge( | ||
| $test_case->get_sample_dom_rect(), | ||
| array( | ||
| 'top' => 100000, | ||
| ) | ||
| ); | ||
| $slug = od_get_url_metrics_slug( od_get_normalized_query_vars() ); | ||
| $sample_size = od_get_url_metrics_breakpoint_sample_size(); | ||
| foreach ( array_merge( od_get_breakpoint_max_widths(), array( 1000 ) ) as $viewport_width ) { | ||
| for ( $i = 0; $i < $sample_size; $i++ ) { | ||
| OD_URL_Metrics_Post_Type::store_url_metric( | ||
|
|
@@ -31,31 +25,31 @@ | |
| 'intersectionRatio' => 0.0, // Subsequent carousel slide. | ||
| ), | ||
| array( | ||
| 'xpath' => '/HTML/BODY/DIV[@id=\'page\']/*[3][self::IMG]', | ||
| 'isLCP' => false, | ||
| 'intersectionRatio' => 0 === $i ? 0.5 : 0.0, // Make sure that the _max_ intersection ratio is considered. | ||
| 'xpath' => '/HTML/BODY/DIV[@id=\'page\']/*[3][self::IMG]', | ||
| 'isLCP' => false, | ||
| 'intersectionRatio' => 0 === $i ? 0.5 : 0.0, // Make sure that the _max_ intersection ratio is considered. | ||
| 'boundingClientRect' => array( | ||
| 'width' => $viewport_width - 10, | ||
| ), | ||
| ), | ||
| // All are outside all initial viewports. | ||
| array( | ||
| 'xpath' => '/HTML/BODY/DIV[@id=\'page\']/*[5][self::IMG]', | ||
| 'isLCP' => false, | ||
| 'intersectionRatio' => 0.0, | ||
| 'intersectionRect' => $outside_viewport_rect, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that the |
||
| 'boundingClientRect' => $outside_viewport_rect, | ||
| 'boundingClientRect' => array( 'top' => 100000 ), | ||
| ), | ||
| array( | ||
| 'xpath' => '/HTML/BODY/DIV[@id=\'page\']/*[6][self::IMG]', | ||
| 'isLCP' => false, | ||
| 'intersectionRatio' => 0.0, | ||
| 'intersectionRect' => $outside_viewport_rect, | ||
| 'boundingClientRect' => $outside_viewport_rect, | ||
| 'boundingClientRect' => array( 'top' => 100000 ), | ||
| ), | ||
| array( | ||
| 'xpath' => '/HTML/BODY/DIV[@id=\'page\']/*[7][self::IMG]', | ||
| 'isLCP' => false, | ||
| 'intersectionRatio' => 0.0, | ||
| 'intersectionRect' => $outside_viewport_rect, | ||
| 'boundingClientRect' => $outside_viewport_rect, | ||
| 'boundingClientRect' => array( 'top' => 100000 ), | ||
| ), | ||
| ), | ||
| ) | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.