Skip to content

Instantly share code, notes, and snippets.

View derekjohnson's full-sized avatar

Derek Johnson derekjohnson

View GitHub Profile
@addyosmani
addyosmani / README.md
Last active May 10, 2025 11:24 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@adactio
adactio / formProgress.js
Created May 29, 2016 15:27
Show a progress bar with every form that has a method of POST. Particularly nice if there's a file upload involved.
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// http://creativecommons.org/publicdomain/zero/1.0/
(function (win, doc) {
'use strict';
if (!win.XMLHttpRequest || !win.FormData || !win.addEventListener || !doc.querySelectorAll) {
// doesn't cut the mustard.
return;
}
function hijaxForm (formElement) {
var progressBar;
@stowball
stowball / front-end-guidelines.md
Last active December 4, 2024 09:58
Front-End Guidelines
@scottjehl
scottjehl / whichones.js
Created August 21, 2020 15:40
which elements are wider than the viewport?
var list = [];
document.querySelectorAll("body *")
.forEach(function(elem){
if(elem.getBoundingClientRect().width > document.body.getBoundingClientRect().width){
list.push(elem.outerHTML.split('>')[0] + '>');
}
});
confirm( "these elements are wider than the viewport:\n\n " + list.join("\n") )
@tkadlec
tkadlec / perf-diagnostics.css
Last active March 20, 2025 08:41
CSS used to highlight potential performance issues
:root {
--violation-color: red; /* used for clear issues */
--warning-color: orange; /* used for potential issues we should look into */
}
/* IMAGES */
/*
* Lazy-Loaded Images Check
* ====
@andydavies
andydavies / index.js
Created January 14, 2021 12:08
Example Cloudflare Worker that removes script preloads
/*
* For more detail see https://andydavies.me/blog/2020/09/22/exploring-site-speed-optimisations-with-webpagetest-and-cloudflare-workers/
* Started from Pat's example in https://www.slideshare.net/patrickmeenan/getting-the-most-out-of-webpagetest
*
* Change site to be site you want to experiment with
*/
const site = 'www.example.com';
async function handleRequest(request) {