Skip to content

Commit 35f6682

Browse files
committed
Merge branch 'main' of github.com:HTTPArchive/almanac.httparchive.org into production
2 parents 26ef6d9 + 0a44f93 commit 35f6682

6 files changed

Lines changed: 277 additions & 123 deletions

File tree

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
CREATE TEMP FUNCTION getLoadingAttr(attributes STRING) RETURNS STRING LANGUAGE js AS '''
2+
try {
3+
const data = JSON.parse(attributes);
4+
const loadingAttr = data.find(attr => attr["name"] === "loading")
5+
return loadingAttr.value
6+
} catch (e) {
7+
return "";
8+
}
9+
''';
10+
11+
CREATE TEMP FUNCTION getDecodingAttr(attributes STRING) RETURNS STRING LANGUAGE js AS '''
12+
try {
13+
const data = JSON.parse(attributes);
14+
const decodingAttr = data.find(attr => attr["name"] === "decoding")
15+
return decodingAttr.value
16+
} catch (e) {
17+
return "";
18+
}
19+
''';
20+
21+
CREATE TEMP FUNCTION getFetchPriorityAttr(attributes STRING) RETURNS STRING LANGUAGE js AS '''
22+
try {
23+
const data = JSON.parse(attributes);
24+
const fetchPriorityAttr = data.find(attr => attr["name"] === "fetchpriority")
25+
return fetchPriorityAttr.value
26+
} catch (e) {
27+
return "";
28+
}
29+
''';
30+
31+
CREATE TEMP FUNCTION getLoadingClasses(attributes STRING) RETURNS STRING LANGUAGE js AS '''
32+
try {
33+
const data = JSON.parse(attributes);
34+
const classes = data.find(attr => attr["name"] === "class").value
35+
if (classes.indexOf('lazyload') !== -1) {
36+
return classes
37+
} else {
38+
return ""
39+
}
40+
} catch (e) {
41+
return "";
42+
}
43+
''';
44+
45+
WITH
46+
lcp_stats AS (
47+
SELECT
48+
client,
49+
page AS url,
50+
JSON_EXTRACT_SCALAR(custom_metrics.performance, '$.lcp_elem_stats.nodeName') AS nodeName,
51+
JSON_EXTRACT_SCALAR(custom_metrics.performance, '$.lcp_elem_stats.url') AS elementUrl,
52+
CAST(JSON_EXTRACT_SCALAR(custom_metrics.performance, '$.lcp_elem_stats.size') AS INT64) AS size,
53+
CAST(JSON_EXTRACT_SCALAR(custom_metrics.performance, '$.lcp_elem_stats.loadTime') AS FLOAT64) AS loadTime,
54+
CAST(JSON_EXTRACT_SCALAR(custom_metrics.performance, '$.lcp_elem_stats.startTime') AS FLOAT64) AS startTime,
55+
CAST(JSON_EXTRACT_SCALAR(custom_metrics.performance, '$.lcp_elem_stats.renderTime') AS FLOAT64) AS renderTime,
56+
JSON_EXTRACT(custom_metrics.performance, '$.lcp_elem_stats.attributes') AS attributes,
57+
getLoadingAttr(TO_JSON_STRING(custom_metrics.performance.lcp_elem_stats.attributes)) AS loading,
58+
getDecodingAttr(TO_JSON_STRING(custom_metrics.performance.lcp_elem_stats.attributes)) AS decoding,
59+
getLoadingClasses(TO_JSON_STRING(custom_metrics.performance.lcp_elem_stats.attributes)) AS classWithLazyload,
60+
getFetchPriorityAttr(TO_JSON_STRING(custom_metrics.performance.lcp_elem_stats.attributes)) AS fetchPriority
61+
FROM
62+
`httparchive.crawl.pages`
63+
WHERE
64+
date = '2024-11-01' AND
65+
is_root_page
66+
)
67+
68+
SELECT
69+
client,
70+
nodeName,
71+
COUNT(DISTINCT url) AS pages,
72+
ANY_VALUE(total) AS total,
73+
COUNT(DISTINCT url) / ANY_VALUE(total) AS pct,
74+
COUNTIF(elementUrl != '') AS haveImages,
75+
COUNTIF(elementUrl != '') / COUNT(DISTINCT url) AS pct_haveImages,
76+
COUNTIF(loading = 'eager') AS native_eagerload,
77+
COUNTIF(loading = 'lazy') AS native_lazyload,
78+
COUNTIF(classWithLazyload != '') AS lazyload_class,
79+
COUNTIF(classWithLazyload != '' OR loading = 'lazy') AS probably_lazyLoaded,
80+
COUNTIF(classWithLazyload != '' OR loading = 'lazy') / COUNT(DISTINCT url) AS pct_prob_lazyloaded,
81+
COUNTIF(decoding = 'async') AS async_decoding,
82+
COUNTIF(decoding = 'sync') AS sync_decoding,
83+
COUNTIF(decoding = 'auto') AS auto_decoding,
84+
COUNTIF(fetchPriority = 'low') AS priority_low,
85+
COUNTIF(fetchPriority = 'high') AS priority_high
86+
FROM
87+
lcp_stats
88+
JOIN (
89+
SELECT
90+
client,
91+
COUNT(0) AS total
92+
FROM
93+
`httparchive.crawl.pages`
94+
WHERE
95+
date = '2024-11-01' AND
96+
is_root_page
97+
GROUP BY
98+
client)
99+
USING
100+
(client)
101+
GROUP BY
102+
client,
103+
nodeName
104+
HAVING
105+
pages > 1000
106+
ORDER BY
107+
pct DESC

sql/2024/performance/lcp_preload_discoverable.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
WITH lcp AS (
22
SELECT
33
client,
4-
JSON_VALUE(custom_metrics, '$.performance.is_lcp_statically_discoverable') = 'true' AS discoverable,
5-
JSON_VALUE(custom_metrics, '$.performance.is_lcp_preloaded') = 'true' AS preloaded
4+
JSON_VALUE(custom_metrics.performance, '$.is_lcp_statically_discoverable') = 'true' AS discoverable,
5+
JSON_VALUE(custom_metrics.performance, '$.is_lcp_preloaded') = 'true' AS preloaded
66
FROM
7-
`httparchive.all.pages`
7+
`httparchive.crawl.pages`
88
WHERE
9-
date = '2024-06-01' AND
9+
date = '2024-11-01' AND
1010
is_root_page
1111
)
1212

src/config/last_updated.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -823,8 +823,8 @@
823823
},
824824
"en/2024/chapters/performance.html": {
825825
"date_published": "2024-11-11T00:00:00.000Z",
826-
"date_modified": "2024-12-02T00:00:00.000Z",
827-
"hash": "c86bcf37df81a0f61b947bae52786648"
826+
"date_modified": "2024-12-10T00:00:00.000Z",
827+
"hash": "d97392736139e6a67779a0ea4dda1f2e"
828828
},
829829
"en/2024/chapters/privacy.html": {
830830
"date_published": "2024-12-03T00:00:00.000Z",

0 commit comments

Comments
 (0)