Skip to content

Instantly share code, notes, and snippets.

View tunetheweb's full-sized avatar

Barry Pollard tunetheweb

View GitHub Profile
@tunetheweb
tunetheweb / CWVs-summary.sql
Created September 14, 2023 18:53
CWVs Summary
#standardSQL
# Core WebVitals by origin
CREATE TEMP FUNCTION IS_GOOD (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS (
SAFE_DIVIDE(good, (good + needs_improvement + poor)) >= 0.75
);
CREATE TEMP FUNCTION IS_POOR (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS (
SAFE_DIVIDE(poor, (good + needs_improvement + poor)) >= 0.25
);
@tunetheweb
tunetheweb / cwv-country-device.sql
Created September 14, 2023 18:54
CWV by country and device
#standardSQL
# Core WebVitals by country
CREATE TEMP FUNCTION IS_GOOD (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS (
SAFE_DIVIDE(good, (good + needs_improvement + poor)) >= 0.75
);
CREATE TEMP FUNCTION IS_POOR (good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS (
SAFE_DIVIDE(poor, (good + needs_improvement + poor)) >= 0.25
);
@tunetheweb
tunetheweb / inject-speculation-rules.html
Last active June 7, 2024 18:01
Inject Speculation Rules
// Paste this into console to prerender all links on hover
function prerenderInAction() {
const script_ = document.createElement('script');
script_.type = 'speculationrules';
script_.textContent = `
{
"prerender": [
{
"where": {
"href_matches": "/*"
<script>
(function () {
function reportWebVitals(metric, debugData) {
var name = metric.name,
delta = metric.delta,
id = metric.id,
navigationType = metric.navigationType,
value = metric.value,
entry = metric.entries[0];