Skip to content

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`(TO_JSON_STRING(custom_metrics.performance)) AS priority
FROM `httparchive.crawl.pages`
WHERE
date = '2023-11-01' AND
client = 'mobile' AND
is_root_page
)
SELECT APPROX_TOP_COUNT(priority, 10) AS priority
FROM lcp

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;
}