Skip to content

Instantly share code, notes, and snippets.

View ethangardner's full-sized avatar

Ethan Gardner ethangardner

View GitHub Profile
pmeenan /
Last active March 18, 2023 16:48
Testing Priority Hints with WebPageTest

Priority Hints is rolling out to Chrome in the 101 release which is currently available in the Dev/Beta channel of Chrome and available in WebPageTest when using the Chrome Canary browser selection.

To make it easier to experiment with priority hints (particularly for LCP images) without making production changes, I set up a couple of public Cloudflare Workers that can be used dynamically with WebPageTest to inject priority hints into existing pages and to preload arbitrary images when combined with WebPageTest's overrideHost script command.

Injecting Priority Hints

There is a cloudflare worker at that will take a CSS selector from the x-hint HTTP header and add fetchpriority=high to any elements in the HTML that match the selector. The easiest way to experiment with this is to use Chrome's dev tools locally, identify the element that hosts the imag

DavidWells / github-proxy-client.js
Last active June 27, 2024 14:52
Full Github REST api in 34 lines of code
/* Ultra lightweight Github REST Client */
// original inspiration via
const token = 'github-token-here'
const githubClient = generateAPI('', {
headers: {
'User-Agent': 'xyz',
'Authorization': `bearer ${token}`
DavidWells / javascript-proxy-as-rest-client.js
Last active May 12, 2024 14:24
Using a javascript proxy as low code REST client
/* Using a JavaScript proxy for a super low code REST client */
// via
// also see
// also see
// also see
// and
const createApi = (url) => {
return new Proxy({}, {
get(target, key) {
jakub-g /
Last active July 15, 2024 12:12
async scripts, defer scripts, module scripts: explainer, comparison, and gotchas

<script> async, defer, async defer, module, nomodule, src, inline - the cheat sheet

With the addition of ES modules, there's now no fewer than 24 ways to load your JS code: (inline|not inline) x (defer|no defer) x (async|no async) x (type=text/javascript | type=module | nomodule) -- and each of them is subtly different.

This document is a comparison of various ways the <script> tags in HTML are processed depending on the attributes set.

If you ever wondered when to use inline <script async type="module"> and when <script nomodule defer src="...">, you're in the good place!

Note that this article is about <script>s inserted in the HTML; the behavior of <script>s inserted at runtime is slightly different - see Deep dive into the murky waters of script loading by Jake Archibald (2013)

ole-boss / Big Query Google Analytics sessions export including site speed metrics.sql
Last active June 13, 2020 14:41
This script helps you creating sessions from Google Analytics raw data on hit level in Google Big Query. The export will also include some metrics related to site speed based on Google's Latency Tracking KPIs.
first_sessions.sid AS sessionId,
first_transactions.transactionId AS transactionId,
mvital / excerpt-as-instant-article-subtitle.php
Created January 11, 2017 15:42 — forked from webdados/excerpt-as-instant-article-subtitle.php
Use WordPress post excerpt as Facebook Instant Article subtitle
/* Instant Articles ( - Use post excerpt as subtitle */
add_filter( 'instant_articles_subtitle', 'hf_instant_articles_subtitle' );
function hf_instant_articles_subtitle( $subtitle ) {
$excerpt = get_the_excerpt();
if ( trim($excerpt)!='' ) $subtitle = trim($excerpt);
return $subtitle;
milon /
Last active November 23, 2022 15:18
Install Elasticsearch on Laravel Homestead

Install Elasticsearch on Laravel Homestead

Install Java

sudo apt-get install openjdk-7-jre-headless -y

Download & install the Public Signing Key

wget -qO - | sudo apt-key add -
mdesanti /
Created February 14, 2016 18:24
Build and upload code to lambda
echo 'Zipping folders for save function'
zip -r node_modules save.js
echo 'Zipped... uploading to AWS'
aws lambda update-function-code --region us-east-1 --function-name saveEmailSubscriptor --zip-file fileb://./ --profile your-profile
echo 'Zipping folders for list function'
zip -r node_modules list.js
echo 'Zipped... uploading to AWS'
aws lambda update-function-code --region us-east-1 --function-name listEmailSubscriptors --zip-file fileb://./ --profile your-profile
jakub-g / _1_"script async defer" blocks "load"
Last active August 22, 2023 10:10
Beware of "script async defer" blocking HTML "load" event

Beware of <script async defer> blocking HTML "load" event

2015.10.07 t

On the importance of simulated latency testing, and bulletproofing your page from the third-party JS load failures