📮 One YouTube Embed weighs almost 1.2 MB
Zach Leatherman 2222 replies 6161 likes4040 reposts Original on MastodonOriginal on BlueskyAlso posted to Mastodon.
22 replies
@zachleat This is what always makes me laugh about how aggressive Google has been with core web vitals—it’s literally their external code that is slowing everything down. When I added a script that replaced YouTube embeds with images, that helped my CWVs a lot.
@ernie Yeah: Google is basically hundreds of different companies—most of Google’s performance advice can be viewed as though it is aimed directly at other teams at Google. I think in many cases the web performance resources were prepared with that in mind.
Notably, the solution I recommend is a web component written by a Google employee 😅
@zachleat I've been playing with the YouTube API and embeds lately as well, but I find it frustrating that if I want to use the API inside and postMessages I *have* to use the whole YT API package. Did you find any way around that?
@Chronotope unfortunately no!
@zachleat As well as saving 1.1MB, I think you also avoid Google tracking your visitors before they've had a chance to decide if they want to click play or not.
@simevidas The "enhanced privacy" mode still isn't as private as not loading anything from YouTube until a visitor makes a choice for it.
@zachleat May as well call it a "California king embed" at that size, amirite?
@hexagoncircle hahahahaha
@zachleat Coincidentally, I was adding a youtube embed "easter egg" on my 404 page this morning. Your post came at the right time! Now uses lite-youtube for those big savings 🙌 https://ryanmulligan.dev/oopsies
@hexagoncircle I love your web site Ryan 😍
@zachleat The idea that one 'youtube embed weighs 1.2 MB' reminds me of something I heard years ago. A government project required developing software going into an airplane. "What does it weight?" "Huh?" "Everything in an airplane has to specify a weight." So, they listed the weight of a floppy disk. This caused a major complaint: "You are way out of line on the price per pound ratio." Finally they explained it as "tooling costs."
@bzdev 😅 can a therapist somewhere please quantify psychological weight
@wills the static maps API for a fallback might be your best bet, maybe this could be a web component you create?
https://developers.google.com/maps/documentation/maps-static/overview
@wills @zachleat I use Mapbox on https://nicolas-hoizey.photo/map/ because it’s interactive.
But on individual photo pages, the map is a static image. At @eleventy build time, if the map image is still missing (generating them is another asynchronous process), I use Mapbox static map URLs.
@wills @zachleat other alternative with WebGl https://maplibre.org/maplibre-gl-js/docs/ (https://bundlephobia.com/package/maplibre-gl@3.6.2)
leaflet is light (https://bundlephobia.com/package/leaflet@1.9.4)
mapbox / googlemaps / bing maps have static maps API
a (really minimal) example with leaflet & protomaps https://pascalmaps.s3.eu-west-2.amazonaws.com/index.html#14/43.5979/1.4391
with a marker + popup :
208 kB transferred
423 kB resources