keyrow's blog

Patching Up

2025-11-06

After my last post about this blog, I thought it was in rather good shape! Then, just as I was to hop off to bed, I decided to see what the real mobile experience was like, and dang, it's a terrible mobile experience.

Why is everything so small??

As I opened up my homepage, I immediately found it hard to even hit any of the links that send me to an actual post. Luckily, the scaling fixes itself (sort of) the moment a post is opened. Why???

I had set up fonts to have a height of 16-18 pixels, so why did it look like it was set to 4 pixels? As it turns out, the viewport width is generally 980px by default (in portrait orientation), no matter the device. This seems to have been a choice made when smartphones became a thing to avoid websites from being completely smushed up when viewed on mobile (try cranking up the zoom on a website to 500% and you can see how usability issues arise).

Also, to make things even more confusing, it turns out the "px" unit in CSS is a "CSS Pixel", which is defined by "1/96th of an inch", not actually a pixel on your screen. Well, actually, this makes some sense to me since display resolutions have only gotten higher, so it would be weird if websites got smaller every time you upgraded your phone.

Anyway, courtesy of a stack overflow answer, it seems the solution to this is just as simple as adding the following into the website header:

<meta name="viewport" content="width=device-width, initial-scale=1">

Problem solved!

Also, from a reddit comment, I found out that setting the padding to 1rem might be a better idea than 1ch.

Bonus Section: Firefox Setup

As it turns out, for testing mobile viewing on desktop, Firefox has a nifty tool called "Responsive Design Mode", which is accessible via the hamburger menu -> More Tools -> Responsive Design Mode. Alternatively, the shortcut "Ctrl + Shift + M" also does the trick.

Optimization

Another thing I realized was that now that I have a functional webpage, I can finally pass in my website to PageSpeed Insights!

Reducing Font Size

Although I thought that 378 KiB was small for a font, it turns out I'm wrong. In fact, it seems like the downloading of the Inter font appears to be the main bottleneck when rendering the site. I'm already using the WOFF2 format, which is already compressed, so further compression here is not ideal. The next best thing I found is font subsetting, which basically means removing unused glyphs from the font being used.

For this, I had a few requirements:

I tried quite a few tools, such as:

I eventually landed on pyftsubset, is the tool being used behind the scenes in Glyphhanger. I figured I could get a bit more control over the output by just using it directly, and I finally got it to subset as I expected.

I used the unicode range given to me by Glyphhanger, which was created by scanning my blog and including the US_ASCII range as well to slightly future-proof the subset. This is the final command I ended up using:

pyftsubset InterVariable.woff2 \
  --output-file=./InterVariable-subset.woff2 \
  --flavor=woff2 \
  --unicodes=U+20-7E \
  --desubroutinize \
  --name-IDs=*

Let's also break it down quickly.

Through this process, I'm left with a nice font subset that is about 40 KiB, which is a 88% size reduction compared to the original 344 KiB. Fantastic!

A quick PageSpeed mobile test shows us that we've gone from a performance score of 89 to 99! Unfortunately, there are still some small accessibility and SEO problems, but I'll get around to that another time.