Skip to content

Instantly share code, notes, and snippets.

View rgourley's full-sized avatar

Robert Gourley rgourley

View GitHub Profile
@rgourley
rgourley / gist:b8d956a5e4a9b6dcf57026eb76d45b02
Created October 31, 2023 22:20
Quickly Find All Font Sizes Used on a Web Page:
(() => {
const fontStyles = {};
document.querySelectorAll('*').forEach(node => {
const computedStyle = window.getComputedStyle(node);
const fontSize = `${parseFloat(computedStyle.getPropertyValue('font-size'))}px`;
const fontFamily = computedStyle.getPropertyValue('font-family').split(',')[0].trim();
const fontWeight = computedStyle.getPropertyValue('font-weight');
const lineHeight = computedStyle.getPropertyValue('line-height');