Skip to content

Commit 71350f3

Browse files
authored
Add function to count color-mix declarations in CSS
1 parent dfb4646 commit 71350f3

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

sql/2025/css/color_mix.sql

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
CREATE TEMPORARY FUNCTION countColorMixDeclarations(css JSON)
2+
RETURNS NUMERIC
3+
LANGUAGE js
4+
OPTIONS (library = "gs://httparchive/lib/css-utils.js")
5+
AS r'''
6+
try {
7+
return countDeclarations(css.stylesheet.rules, {values: /color-mix\(.*\)/});
8+
} catch (e) {
9+
return null;
10+
}
11+
''';
12+
13+
SELECT
14+
client,
15+
COUNT(DISTINCT IF(declarations > 0, page, NULL)) AS pages,
16+
COUNT(DISTINCT page) AS total,
17+
COUNT(DISTINCT IF(declarations > 0, page, NULL)) / COUNT(DISTINCT page) AS pct_pages
18+
FROM (
19+
SELECT
20+
client,
21+
page,
22+
countColorMixDeclarations(css) AS declarations
23+
FROM
24+
`httparchive.crawl.parsed_css`
25+
WHERE
26+
date = '2025-07-01' AND
27+
rank <= 1000000
28+
)
29+
GROUP BY
30+
client

0 commit comments

Comments
 (0)