Skip to content

Instantly share code, notes, and snippets.

View tunetheweb's full-sized avatar

Barry Pollard tunetheweb

View GitHub Profile
@tunetheweb
tunetheweb / http_archive_css_alternate.sql
Created May 23, 2020 11:19
Percent of pages that include link[rel=alternate] for stylesheets
#standardSQL
# Percent of pages that include link[rel=alternate] for stylesheets
# Warning this uses 500GB of BigQuery usage so can be expensive to run multiple times!
CREATE TEMP FUNCTION hasAlternateCSS(payload STRING)
RETURNS BOOLEAN LANGUAGE js AS '''
try {
var $ = JSON.parse(payload);
var almanac = JSON.parse($._almanac);
return !!almanac['link-nodes'].find(
e => e.rel.toLowerCase().includes('alternate')

How many <img> elements have width and height attributes?

Query based on similar query about sizes and srcset created by Colin Bendell for the 2019 Web Almanac

This takes about 850GB to run for 2019 this produces the following results:

Row client hasHeight hasWidth hasPicture total pctHeight pctWidth pctPicture
1 mobile 3415295 3548809 108589 5447942 62.69% 65.14% 1.99%
2 desktop 2794913 2900974 94251 4474762 62.46% 64.83% 2.11%