2025-03-01
• blog • 460 words
Huge gains by very simple changes.
(I'm not sure whether to release this blog post on 2025-03-01 or 2025-03-02 - as I write it's the 2nd, but it's because it's only just gone midnight. Really, I should be in bed right now. Oh, also, this is entry 4 of 200DaysToOffload)
I have been looking at the 512kb club website, and wondered quickly what size my website was. It's just text and an image, so it can't be that big, right?
It was 1.5MB downloaded. Oh no.
Inspecting it with the Network tab under Inspect, there were two files that were the culprits: the image of myself on the homepage, and the font.
The image of me was in JPG, and was actually already ensmallened (not a word) a bit from the original. It is 991kb: I clearly need to lose some weight. The font, EB Garamond, was in TTF format and was 561kb.
I decided to go full modern-day on the JPG, and convert it into this fancy fandangled new format called "Web P". I'm not sure what the P is for. I apparently already had libwebp installed, so I used cwebp to generate the photo. With the default compression applied (which is, granted, quite noticeable) it gets it down to 36kb. A full 955kb (almost a megabyte) saved just from that alone.
Unfortunately, the 561kb font was still prohibiting me from actually being less than 512kb, and so preventing me from joining the club and being cool and having friends.
The font file is in an archaic format, invented in 1941 by Alan Turing, called TTF. This is short for "TTF Type Font". It was used to display messages encoded by the Enigma machine.
I decided again to join the modern day, and utilise a font format which is so new it is still considered unstable. It is called "WOFF2", which stands for "Web-Only Font Format 2". Under section 14 article 6 of the EU Web Font Directive, passed into UK law in 2022 due to clerical error where it was missed that the UK is no longer a member of the European Union, and so is no longer compelled to implement directives, it is a crime punishable by a fine of up to £2500 or a six-month prison sentence to use the WOFF2 format outside of the contexts of a website or a spider's nest.
I initially downloaded a program here, compiled it with `make`, and converted it. The resultant font file, however, was in WOFF1! And, it was still 224kb! Borderline criminal. So, I installed webfont-kit-generator, and created a WOFF2 format from that. In two files (one for Latin, and the other Latin extended) it produced WOFF2 files totalling 59k. Very nice!
With that, I now have a website that in all, is only 64kb for the main page. As a result, my home page is now 96 percent smaller! And, essentially all I have done is compress two assets.