Skip to content

Instantly share code, notes, and snippets.

@dfranklinau
dfranklinau / slow-page-speed-detection.md
Last active January 8, 2026 04:28
Slow page speed detection

Slow page speed detection

The following HTML uses JavaScript to create a lightweight banner that displays to users whose page does not load within a specified time.

Use network throttling within browser developer tools to preview locally.

<!DOCTYPE html>
<html lang="en">
<head>
@dfranklinau
dfranklinau / alt-text-bookmarklet.md
Last active February 20, 2024 11:45
alt text bookmarklet

alt text bookmarklet

Use this bookmarklet to insert a span above all img elements with an alt attribute:

javascript:(function(){var images=document.querySelectorAll("img[alt]");images.forEach(image=>{var altText=document.createElement("span");altText.appendChild(document.createTextNode(image.getAttribute("alt")));altText.classList.add("js-bookmarklet-image-alt");image.parentNode.insertBefore(altText,image)});var style=document.createElement("style");document.head.appendChild(style);var styleSheet=style.sheet;styleSheet.insertRule(".js-bookmarklet-image-alt { display: block; border: 1px solid black; border-bottom: 0; padding: 0.5rem 1rem; background-color: ghostwhite; font-family: inherit; }")})();

Source