Skip to content

feat(book): image-quality and offline-images for light illustrated books - #18

Merged
apiad merged 1 commit into
mainfrom
feat/light-images
Oct 20, 2026
Merged

apiad merged 1 commit into
mainfrom
feat/light-images

Conversation

@apiad

@apiad apiad commented Oct 20, 2026

Copy link
Copy Markdown
Owner

Closes #17.

  • image-quality (html output, default 80) sets the WebP quality. At the default the image names stay as they were, so existing books do not change edition.
  • offline-images (default true, today's behaviour). With false: img/ leaves the precache list, each image gets loading="lazy" decoding="async", and the worker caches an image the first time it is fetched.
  • #measure moves to translate(-100000px, -100000px). Chrome fetches lazy images within about a screen of the viewport even under visibility:hidden. At -200vw a phone fetched the first image of every chapter while counting pages.

Measured on a 23-chapter book with 245 illustrations (720 px, quality 60, offline-images: false): the first visit downloads about 1 MB, with one image (the cover). Opening a chapter and turning three pages fetches 4 more. Before, the whole 46 MB came down on install.

Tests: unit tests for quality and lazy tags, the precache list without img/, and a browser test that counting pages fetches no image of an unopened chapter. That test fails on phone with the old -200vw offset. uv run pytest: 349 passed. -m browser: 20 passed.

🤖 Generated with Claude Code

offline-images: false keeps img/ out of the service worker's precache, marks
every image loading=lazy and caches each image when it is first fetched.
The counting strip moves far off screen, because Chrome fetched the first
lazy image of every chapter at -200vw on a phone. image-quality sets the WebP
quality; the default keeps the old image names, so existing books keep their
edition.

Closes #17

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@apiad
apiad merged commit f1cc53e into main Oct 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTML book: light images for the web (quality option, no image precache)

1 participant