Webcomics R&D

Speed & download size

Making webcomics faster

  1. Make the comic load ASAP. Everything else is second to this.
    • Image optimization
    • Play nice with the preload scanner
    • General-purpose website optimizations that apply here: critical CSS, HTTP keepalive, HTTP/2…
    • If the comic uses webfonts…
    • link[rel=preload][as=font] and make sure they’re cacheable. (Luckily, you only really have to care about WOFF2 nowadays.)
    • Use @font-face descriptors and font-size-adjust to avoid reflow; especially now that Firefox and Safari support font-size-adjust
    • Avoid client-side rendering/SPAs or suffer the Honey Crab problem
  2. Then load everything else
    • Beware third-party scripts, and be firm with them
You really don’t want the rest of your website to compete with the comics’ loading
You should try a system font stack for text outside your comics. https://wiki.mobileread.com/wiki/List_of_fonts_included_with_each_device https://iainbean.com/posts/2021/system-fonts-dont-have-to-be-ugly/

Image formats & optimization

The preload scanner

Speed up archive reading by loading the next page while you read the current one

The core idea isn’t complicated, but for historical reasons there are different ways to accomplish it.

<link rel="next prefetch"> for faster reading for those going through your archives (note WordPress does next by default). However, apparently Firefox doesn’t honor prefetch for HTTPS pages, which sucks. So instead…

<link rel="prerender"> and unfortunately also the speculationrules API

All together now, if the user is on /page/1:

<link rel="next prefetch prerender" href="/page/2"> <!-- test to see if these need to split these into multiple <link> elements, I remember Safari not recognizing <link rel="dns-prefetch preconnect"> -->
<script type="speculationrules">
  { "prerender": [
    { "source": "list", "urls": ["/page/2"] }
  ]}
</script>

I’m omitting something like <link rel="prefetch" href="/page/2/first-image.png"> because I have no idea how that would work with images that use srcset. (Well, wait, there’s imagesrcset…)

Note: <link rel="preload"> is unsuitable, as it’s designed for immediately loading something on the current page. Unfortunately, it’s very easy to mix up the words “prefetch” and ”preload”, so read carefully wnenever you find information about one or the other.

Service Worker precaching?