-
-
Notifications
You must be signed in to change notification settings - Fork 183
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
Performance 2024: image prioritization and discoverability #3960
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bd476f6
Update lcp_preload_discoverable.sql
rviscomi 07aa015
Create lcp_async_fetchpriority.sql
rviscomi a8e0be8
Add prioritization and discoverability stats
rviscomi 0e1b03d
% with unsized images
rviscomi b34a4d5
Update src/content/en/2024/performance.md
rviscomi e9aa770
"lazy loading"
rviscomi 22cd28c
minor editing
rviscomi c20350c
note about native lazy loading discoverability
rviscomi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
CREATE TEMP FUNCTION getLoadingAttr(attributes STRING) RETURNS STRING LANGUAGE js AS ''' | ||
try { | ||
const data = JSON.parse(attributes); | ||
const loadingAttr = data.find(attr => attr["name"] === "loading") | ||
return loadingAttr.value | ||
} catch (e) { | ||
return ""; | ||
} | ||
'''; | ||
|
||
CREATE TEMP FUNCTION getDecodingAttr(attributes STRING) RETURNS STRING LANGUAGE js AS ''' | ||
try { | ||
const data = JSON.parse(attributes); | ||
const decodingAttr = data.find(attr => attr["name"] === "decoding") | ||
return decodingAttr.value | ||
} catch (e) { | ||
return ""; | ||
} | ||
'''; | ||
|
||
CREATE TEMP FUNCTION getFetchPriorityAttr(attributes STRING) RETURNS STRING LANGUAGE js AS ''' | ||
try { | ||
const data = JSON.parse(attributes); | ||
const fetchPriorityAttr = data.find(attr => attr["name"] === "fetchpriority") | ||
return fetchPriorityAttr.value | ||
} catch (e) { | ||
return ""; | ||
} | ||
'''; | ||
|
||
CREATE TEMP FUNCTION getLoadingClasses(attributes STRING) RETURNS STRING LANGUAGE js AS ''' | ||
try { | ||
const data = JSON.parse(attributes); | ||
const classes = data.find(attr => attr["name"] === "class").value | ||
if (classes.indexOf('lazyload') !== -1) { | ||
return classes | ||
} else { | ||
return "" | ||
} | ||
} catch (e) { | ||
return ""; | ||
} | ||
'''; | ||
|
||
WITH | ||
lcp_stats AS ( | ||
SELECT | ||
client, | ||
page AS url, | ||
JSON_EXTRACT_SCALAR(custom_metrics.performance, '$.lcp_elem_stats.nodeName') AS nodeName, | ||
JSON_EXTRACT_SCALAR(custom_metrics.performance, '$.lcp_elem_stats.url') AS elementUrl, | ||
CAST(JSON_EXTRACT_SCALAR(custom_metrics.performance, '$.lcp_elem_stats.size') AS INT64) AS size, | ||
CAST(JSON_EXTRACT_SCALAR(custom_metrics.performance, '$.lcp_elem_stats.loadTime') AS FLOAT64) AS loadTime, | ||
CAST(JSON_EXTRACT_SCALAR(custom_metrics.performance, '$.lcp_elem_stats.startTime') AS FLOAT64) AS startTime, | ||
CAST(JSON_EXTRACT_SCALAR(custom_metrics.performance, '$.lcp_elem_stats.renderTime') AS FLOAT64) AS renderTime, | ||
JSON_EXTRACT(custom_metrics.performance, '$.lcp_elem_stats.attributes') AS attributes, | ||
getLoadingAttr(TO_JSON_STRING(custom_metrics.performance.lcp_elem_stats.attributes)) AS loading, | ||
getDecodingAttr(TO_JSON_STRING(custom_metrics.performance.lcp_elem_stats.attributes)) AS decoding, | ||
getLoadingClasses(TO_JSON_STRING(custom_metrics.performance.lcp_elem_stats.attributes)) AS classWithLazyload, | ||
getFetchPriorityAttr(TO_JSON_STRING(custom_metrics.performance.lcp_elem_stats.attributes)) AS fetchPriority | ||
FROM | ||
`httparchive.crawl.pages` | ||
WHERE | ||
date = '2024-11-01' AND | ||
is_root_page | ||
) | ||
|
||
SELECT | ||
client, | ||
nodeName, | ||
COUNT(DISTINCT url) AS pages, | ||
ANY_VALUE(total) AS total, | ||
COUNT(DISTINCT url) / ANY_VALUE(total) AS pct, | ||
COUNTIF(elementUrl != '') AS haveImages, | ||
COUNTIF(elementUrl != '') / COUNT(DISTINCT url) AS pct_haveImages, | ||
COUNTIF(loading = 'eager') AS native_eagerload, | ||
COUNTIF(loading = 'lazy') AS native_lazyload, | ||
COUNTIF(classWithLazyload != '') AS lazyload_class, | ||
COUNTIF(classWithLazyload != '' OR loading = 'lazy') AS probably_lazyLoaded, | ||
COUNTIF(classWithLazyload != '' OR loading = 'lazy') / COUNT(DISTINCT url) AS pct_prob_lazyloaded, | ||
COUNTIF(decoding = 'async') AS async_decoding, | ||
COUNTIF(decoding = 'sync') AS sync_decoding, | ||
COUNTIF(decoding = 'auto') AS auto_decoding, | ||
COUNTIF(fetchPriority = 'low') AS priority_low, | ||
COUNTIF(fetchPriority = 'high') AS priority_high | ||
FROM | ||
lcp_stats | ||
JOIN ( | ||
SELECT | ||
client, | ||
COUNT(0) AS total | ||
FROM | ||
`httparchive.crawl.pages` | ||
WHERE | ||
date = '2024-11-01' AND | ||
is_root_page | ||
GROUP BY | ||
client) | ||
USING | ||
(client) | ||
GROUP BY | ||
client, | ||
nodeName | ||
HAVING | ||
pages > 1000 | ||
ORDER BY | ||
pct DESC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If an LCP image is lazy loaded (natively) then it is still statically discoverable. Only custom approaches (6.7% of sites) are included in the 35%. Might be worth clarifying.
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.
Effectively not. It's not discoverable by the preload scanner, and needs CSS to run layout to know if it's in viewport. Which effectively means it's not statically discoverable (i.e. it's the same as if it was hidden in CSS background image, or within JS that needs to run).
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.
Fair enough, but the custom metric definition of
is_statically_discoverable
doesn't take this into consideration.The image is considered statically discoverable if it is preloaded or available in the image
src
orsrcset
: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.
Good point @kevinfarrugia, I think it's at least worth mentioning that native lazy loading isn't included in the static discoverability stat. We might want to consider looking at a different high-level metric in the future that captures all of the causes of resource load delay.
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.
Updated PTAL