diff --git a/sql/2021/resource-hints/imgLazy.sql b/sql/2021/resource-hints/imgLazy.sql new file mode 100644 index 00000000000..eefcdbbc33f --- /dev/null +++ b/sql/2021/resource-hints/imgLazy.sql @@ -0,0 +1,15 @@ +#standardSQL +SELECT + SUBSTR(_TABLE_SUFFIX, 0, 10) AS date, + IF(ENDS_WITH(_TABLE_SUFFIX, 'desktop'), 'desktop', 'mobile') AS client, + COUNT(DISTINCT IF(LOWER(attr) = '"lazy"', url, NULL)) / COUNT(DISTINCT url) AS percent +FROM + `httparchive.pages.*` +LEFT JOIN + UNNEST(JSON_EXTRACT_ARRAY(JSON_EXTRACT_SCALAR(payload, "$['_img-loading-attr']"), '$')) AS attr +GROUP BY + date, + client +ORDER BY + date DESC, + client