Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Reducing Asset Size with Subsetting (bytes.zone)
26 points by luu on March 8, 2020 | hide | past | favorite | 6 comments


FYI, this is common enough that Google Fonts has subsetting built in.

You can use the Google Fonts API's 'text' parameter to specify specific glyphs, or you can use the more-general 'subset' property (e.g. subset=greek,cyrillic) to choose one or more scripts.

https://developers.google.com/fonts/docs/getting_started


Neat idea. My approach to solving this issue was configuring nginx to gzip responses with a high compression ratio. You can also precompress your asset files and tell nginx to find and serve the “.gz” compressed version of a static asset if available. This alleviates additional compute load imposed by Enabling compression.


I immediately jumped to “why don’t we just compress them?” and it turns out I was wrong. The author is using the WOFF format (https://en.wikipedia.org/wiki/Web_Open_Font_Format) which is already compressed with zlib using a special encoding. Serving them gzipped is unnecessary.


If you are interested in reducing the font size, consider variable fonts. They are supported in pretty much every browser that matters. Although the file size is larger, it often is smaller when regular, italic, and bold variants put together.

When sunsetting, it's important to use a good alt don't too, so even if the glyph is missing from the font, it doesn't look too bad with the alt system font.



Incredible! Thought of doing this at the app level, but hadn't thought of italics etc. The concept of doing it with puppeteer is pretty neat.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: