Repository navigation
Commit 2ff696a
authored
perf(website): size the hero poster to the box it paints in (#1062)
Closes #876
### What changed
`website/site/public/media/hero-poster.webp` is encoded at **1440×810**
instead of 1920×1080, and `scripts/build-media.mjs` resizes to 1440 so
the next `pnpm run media` keeps the size instead of restoring 1920.
1440 covers the box the film actually paints in: `Hero.astro` caps it at
`min(1180px, 80vw, film-h * 16/9)`, so at most 1180×664 CSS px — 1440 is
**1.22×** that, enough for a 1.25× display, and no `devicePixelRatio`
branch is needed. The 1359×764 in #876 was the layout before that cap
landed in #899, two days after the audit; the issue's numbers describe a
box the site no longer has.
### Before / after
| | bytes | dimensions |
|---|---|---|
| before | 42,926 | 1920 × 1080 |
| after | **30,878** | 1440 × 810 |
**−12,048 B, −28.1%.** Both below the issue's ≤ 45 KB bound.
Note the source file was already smaller than the 73,916 B the
2026-10-17 audit measured — it was re-encoded during the #858 rebrand —
so the absolute saving is smaller than the audit's 36.9 KiB estimate,
while the resolution waste it reported is removed.
### Visual check
SSIM of the new file against the old one, both scaled with lanczos to
the comparison size:
| comparison size | SSIM |
|---|---|
| 1180 × 664 (the film's CSS cap today) | 0.9968 |
| 1359 × 764 (the layout #876 measured) | 0.9964 |
| 2718 × 1528 (2× device pixels) | 0.9932 |
### `og:image` was never this file
The issue's second consumer no longer exists: `Base.astro` defaults
`ogImage` to `/media/social-card.png`, generated at 1200×630 by
`build-social-card.mjs` (#884). Nothing overrides it — `grep -rn
"ogImage=" website/site/src` returns only the default and the prop
declaration. So the "must stay 1920×1080" constraint does not apply, and
no second 1920 file is kept.
Built output confirms both:
```
dist/media/hero-poster.webp 30,878 B 1440,810
poster="/media/hero-poster.webp"
property="og:image" content="https://nostream.dev/media/social-card.png"
```
### Verification
- `pnpm build` in `website/site` succeeds (prebuild's brand + hero-NIP
checks included); the asset in `dist/media/` is the new one at 30,878 B.
- CLS: the film keeps `aspect-ratio: 16/9` on the `<video>`, unchanged
by this PR, so the poster's intrinsic size does not enter layout.
### Out of scope
`admin-poster.webp` and `peering-poster.webp` are encoded by the same
script at 1920 and have the same geometry mismatch. They are not
measured by this issue's audit and are left alone; the fix is one
`resize()` call each when someone measures them.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Performance**
* Reduced the landing page hero image width from 1920 to 1440 pixels,
lowering the image’s download size while preserving visual quality.
* Social preview imagery remains unchanged.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->3 files changed
Lines changed: 26 additions & 1 deletion
File tree
- .changeset
- website/site
- public/media
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
Loading
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
38 | 44 | | |
39 | 45 | | |
40 | | - | |
| 46 | + | |
41 | 47 | | |
42 | 48 | | |
43 | 49 | | |
| |||
0 commit comments