GET_LCP_PRIORITY function
The httparchive.fn.GET_LCP_PRIORITY
function returns the value of the fetchpriority
attribute of the LCP element.
Input
performance_custom_metric
The JSON-encoded performance
custom metric of a page.
Type: STRING
Output
The value of the fetchpriority
attribute of the LCP element, or null
if the LCP element does not have a fetchpriority
attribute.
Type: STRING
Example usage
Top fetchpriority
values
WITH lcp AS (
SELECT
`httparchive.fn.GET_LCP_PRIORITY`(JSON_QUERY(custom_metrics, '$.performance')) AS priority
FROM
`httparchive.all.pages`
WHERE
date = '2023-11-01' AND
client = 'mobile' AND
is_root_page
)
SELECT
APPROX_TOP_COUNT(priority, 10) AS priority
FROM
lcp
priority.value | priority.count |
---|---|
null | 15892076 |
high | 697184 |
low | 5103 |
auto | 3255 |
hight | 24 |
highest | 17 |
"" | 14 |
”high” | 4 |
High | 4 |
medium | 3 |
Routine
try {
const perf = JSON.parse(performance_custom_metric);
const lcpAttrs = perf.lcp_elem_stats.attributes;
return lcpAttrs.find(attr => attr.name == 'fetchpriority')?.value
} catch {
return null;
}