Faffing with fonts to reduce my web page size by two thirds
I like the Monorale font: like Railway, but with some of the fancier bits removed.
I also like my webpages to be small, and also to host things myself (i.e. no CDN or third party font hosting).
Loading the index page of decoded.legal is 370kB. Not massive, by any means, but I wondered if it could be smaller.
Using the Monorale font adds an additional 140ish kB to each initial load of my site, per font. So multiplied by two when I use italics, three when I use bold, and so on.
-rw-r--r-- 1 neil neil 140544 2024-05-03 08:15 Monorale-Italic.otf
-rw-r--r-- 1 neil neil 143888 2024-05-03 08:15 Monorale-Regular.otf
So I wondered if I could strip out glyphs that I don’t use / am unlikely to use, and what the impact would be.
fonttools
I used:
pipx install fonttools
pyftsubset Monorale-Regular.otf --output-file=Monorale-Regular_reduced.otf --unicodes=U+0020-007E
As I understand it, this keeps only the basic Latin characters.
The reduction is quite significant:
-rw-r--r-- 1 neil neil 10064 2024-05-03 08:27 Monorale-Italic_reduced.otf
-rw-r--r-- 1 neil neil 9580 2024-05-03 08:26 Monorale-Regular_reduced.otf
Fonts would now account for 20kB, rather than 280kB.
Now, loading the index page of decoded.legal is 110kB, so over a third smaller.
I could perhaps trim off another 2 or 3kB by switching to .woff.
Is this a bad idea?
I don’t know!
I’ve had a quick (manual) look through the site, to see if there are any obvious font errors, and I haven’t seen any. It doesn’t mean that they are not there.
But, if it does work, amazing.
And if it does not, I can always revert, or try a different reduced set of glyphs.
So now if I could just trim down the 70kB of JavaScript (i.e. not having a drop-down menu) and css…
(I haven’t done my blogs yet; perhaps over the weekend.)
You may also like:
- The wireless ambidextrous Penguin Posturite mouse and Linux
- VoIP XML config examples for FireBrick
- Changing the default resize value in nautilus-image-converter
- Geek Code: a piece of web history
- Comparing Lenovo's Active Pen and Active Pen 2 for writing on a ThinkPad X1 Yoga Gen 2 using Debian Linux
- I have data and documents in too many places
- Making other people's websites look how I want them to look
- Scanning to Debian 12 with a Fujitsi ix500
- When is a website too simple?
- Creating a partition larger than 2TB on an SSD on Linux
- Saving money via AliExpress v Amazon
- In memoriam: A&A's SIP2SIM service
- Multiplayer Quake III Arena on Linux (client and server)
- EE data SIM expiry
- Storing config options for yt-dlp in a config file