How I Doubled My Lighthouse Performance Score in One Night The article describes how the author improved their website's Lighthouse performance score from 48 to nearly double by optimizing web fonts and refactoring a YouTube embed. They reduced font file sizes by 56% through subsetting and replaced a heavy YouTube playlist embed with a lightweight web component called `lite-youtube-embed`. These changes significantly improved the site's performance metrics, including Time to Interactive and contentful paint. Special thanks to Matthias Ott, whose post about enjoying meta-updates about personal sites was the encouragement I needed to go ahead and blog about some work I’d done. Introduction Last night, I was on a kick. I wasn’t happy with this site’s web performance. Lighthouse scans were scoring my homepage 48 out of a possible 100 points on performance. The Website Carbon Calculator was reporting that each load of my homepage emitted 7.8 grams of carbon dioxide, making it dirtier than 97% of the pages they had tested before. These scores seemed really, really surprising to me, especially given that this site doesn’t use any clientside frameworks, and is instead wholly pregenerated static assets built with Eleventy — it shouldn’t be that heavy or slow. There had to be some things I could do to improve the site’s performance. Optimizing Fonts The first piece of performance I chose to tackle was web font performance, since I hadn’t had any experience with it yet. Specifically, I figured I could improve the performance around my brand font Nexa, which I’m self-hosting. To start, I looked for each variant of Nexa that was present on my site, as well as how much they weighed. Here’s what I found: Each variant cost about 60 kilobytes. The browser was only downloading the variants present on a given page, but that usually meant only one or maybe two variants would be culled on a page load. I found that one variant, Nexa 400 Regular, was only used for one thing: the date-posted stamps on each article. I opted to replace that with the Nexa 300 Regular, which was a quick 60 kilobytes saved. To really cut down on font bundle sizes, I turned to subsetting, or removing unused glyphs from the font files themselves to serve only the glyphs you need. This is especially helpful to cut out alphabets of languages you aren’t writing in, as well as a bunch of other Unicode characters for things like arrows or mathematical symbols. Markos Konstantopoulos’s article on creating font subsets was hugely helpful here, and it guided me through using Zach Leatherman’s glyphhanger project to identify the character ranges I needed to include in my subsets, and through using pyftsubset to create subsets of my font files. I chose a bare minimum subset pretty much just the ASCII range for the light Nexa 300 Regular and Italic subsets, since those variants are used in very particular pieces of the page. I chose more lenient subsets for the 700 and above variants, since those are used in headings, link text, and more. I could eke much more performance savings with more aggressive ranges there. As it stands, here are the current sizes with the subsets I’ve gone with: All in all, this means the total size of Nexa downloads is now about 44% the size of the original, which I’m pretty happy with. However, playing with font bundles alone didn’t seem to move the needle all that much for Lighthouse. It was a good learning experience, but more drastic improvements needed to be made. Refactoring the YouTube Embed When run against my homepage, the Lighthouse scans were pointing towards one major culprit: the YouTube playlist embed for my Some Antics streams. Lighthouse warned me that this embed alone seemed to be bringing my Time to Interactive up quite a bit, as well as messing with my contentful paint metrics. I decided to check out Paul Irish’s lite-youtube-embed project. This project introduces a