Skip to content

Instantly share code, notes, and snippets.

View rviscomi's full-sized avatar

Rick Viscomi rviscomi

View GitHub Profile
@rviscomi
rviscomi / httparchive.md
Last active April 21, 2024 19:59
Documentation of the HTTP Archive payload in BigQuery, generated by ChatGPT and not verified for accuracy

Timing information

Properties related to the timing of various events during the page load process, such as the time it takes for the page to load, the time to the first byte, and the time for different elements of the page such as images and stylesheets to be loaded, paint and rendered.

Request and response information

Properties related to the number and size of requests and responses made during the page load process, such as the number of requests, the number of responses with different status codes, and the total size of data transferred.

Test information

@rviscomi
rviscomi / timedChunk.js
Created September 5, 2012 19:00
Timed chunk
/*! Copyright 2009 Nicholas C. Zakas. All rights reserved. MIT Licensed */
/**
* Processes each item in "items" at most 50ms at a time with a sleep of 25ms.
* By limiting the amount of time spent in a loop, there is no lock on the UI thread.
*
* Calls "process" in "context" for each item in "items".
* After each item has been processed, "callback" is called with the original array.
*
* Some modifications to Zakas's code:
* * added delay parameter to control how long to sleep
@rviscomi
rviscomi / http-equiv-data.csv
Last active July 21, 2023 15:00
HTTP Archive data on `http-equiv` usage from June 2023 (Top 200)
rank value sites valid conforming
1 x-ua-compatible 6,469,282
2 content-type 4,570,525
3 origin-trial 4,136,699
4 content-language 487,072
5 cache-control 441,570
6 etag 438,906
7 x-wix-published-version 438,666
8 x-wix-application-instance-id 438,665
9 x-wix-meta-site-id 438,665
import {
onCLS,
onFID,
onLCP,
onINP
} from 'https://unpkg.com/web-vitals@3/dist/web-vitals.attribution.js?module';
function sendToGoogleAnalytics({name, delta, value, id, rating, navigationType, attribution}) {
const eventParams = {
value: delta,
@rviscomi
rviscomi / wpt_lcp_rld.js
Created May 25, 2023 15:47
WebPageTest custom metric to measure the LCP resource load delay diagnostic.
[lcp_rld]
// https://web.dev/optimize-lcp/#monitor-lcp-breakdown-in-javascript
return new Promise(resolve => {
new PerformanceObserver((list) => {
const lcpEntry = list.getEntries().at(-1);
const navEntry = performance.getEntriesByType('navigation')[0];
const lcpResEntry = performance
.getEntriesByType('resource')
.filter((e) => e.name === lcpEntry.url)[0];
@rviscomi
rviscomi / bigquery-web-vitals.sql
Created April 28, 2023 18:52
Create a BigQuery view to summarize the Web Vitals data from GA and a helper function for restricting the date range
CREATE OR REPLACE VIEW httparchive.analytics_373060815.web_vitals AS (
SELECT
event_name AS metric_name,
* EXCEPT(event_name, is_last_received_value)
FROM (
SELECT
*,
REGEXP_SUBSTR((SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'page_location'), r'\/\/.*?(\/[^?]*)') AS page_path,
ROUND((SELECT COALESCE(value.double_value, value.int_value) FROM UNNEST(event_params) WHERE key = 'value'), 3) AS metric_value,
IF (ROW_NUMBER() OVER (PARTITION BY (
@rviscomi
rviscomi / lorem-ipsum.js
Created December 15, 2011 03:06
JavaScript Lorem Ipsum Generator
/**
* @fileOverview Generates "Lorem ipsum" style text.
* @author rviscomi@gmail.com Rick Viscomi,
* tinsley@tinsology.net Mathew Tinsley
* @version 1.0
*/
/**
* Copyright (c) 2009, Mathew Tinsley (tinsley@tinsology.net)
* All rights reserved.
WITH app_list AS (
SELECT DISTINCT
app
FROM
`httparchive.technologies.2022_05_01_mobile`
WHERE
category IN ('CMS')
), category AS (
SELECT
_TABLE_SUFFIX,
{
"pageref": "page_1_0_1",
"_run": 1,
"_cached": 0,
"startedDateTime": "2022-05-13T16:17:30.615041",
"time": 623,
"request": {
"method": "GET",
"url": "https://m.twfanti.com/search.html",
"headersSize": 672,
@rviscomi
rviscomi / getIfConditionals.sql
Last active March 23, 2022 17:04
Analysis of the top SCSS `if` conditionals using HTTP Archive data from March 2022 (mobile). See the full results at https://docs.google.com/spreadsheets/d/1ZMoqLRu2OpBDi-kLgJdTzAAkZwPeHe5sLHjTjt5vEng/edit?usp=sharing and https://github.com/w3c/csswg-drafts/issues/6684#issuecomment-1076543094 for more context.
CREATE TEMPORARY FUNCTION getIfConditionals(payload STRING) RETURNS
ARRAY<STRING> LANGUAGE js AS '''
try {
var $ = JSON.parse(payload);
var sass = JSON.parse($['_sass']);
return sass.scss.stats.ifs.map(i => i.test);
} catch (e) {
return [];
}