web: ship the logo at display size, and serve WebP when the browser takes it

logo.png was a 1920x1920 RGBA render (492 KB) used as a 40 px sidebar mark, a
160 px login mark, and the favicon. It was the single largest item on the page:
32% of the 1.55 MB asset budget, and incompressible, so it outweighed the entire
gzip saving from the caching work in #404.

- public/logo.png   1920 -> 512 (3x the largest 160 px display)   492 KB -> 71 KB
- public/logo.webp  new, same 512 art                             492 KB -> 28 KB
- app/icon.png      1920 -> 192 (favicon)                         492 KB -> 17 KB

The three <img src=/logo.png> sites sit in a <picture> with a WebP source and the
PNG as fallback. The wrapper needs className="contents": <picture> is
display:block by default, so as a flex item it took over the image's layout slot
and — in the collapsed sidebar, whose button is size-8 with p-2 — the logo came
out at 3.5 px instead of the ~16 px it had. With display:contents the wrapper
generates no box and the <img> is the flex item again; measured in the built
export, an <img width=40> in that button is 16x16 px with the bare-img markup,
3.52x3.52 with a plain <picture> wrapper, and 16x16 with <picture
className="contents">. The login/setup marks measure 160x160 either way.

No component or CSS changes beyond the wrapper; the built CSS contains
.contents{display:contents}.
This commit is contained in:
Pedro Gomes
2026-11-22 14:44:51 +00:00
parent ab40834567
commit b61306f7a8
6 changed files with 12 additions and 3 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 480 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

+4 -1
View File
@@ -100,7 +100,10 @@ export default function LoginPage() {
<div className="absolute size-60 rounded-full border border-primary-foreground/15" />
<div className="absolute size-40 rounded-full border border-primary-foreground/20" />
{/* eslint-disable-next-line @next/next/no-img-element */}
<img src="/logo.png" alt="ARTEX" width={160} height={160} className="relative brightness-0 invert" />
<picture className="contents">
<source srcSet="/logo.webp" type="image/webp" />
<img src="/logo.png" alt="ARTEX" width={160} height={160} className="relative brightness-0 invert" />
</picture>
</div>
</div>
+4 -1
View File
@@ -70,7 +70,10 @@ export default function SetupPage() {
<div className="absolute size-60 rounded-full border border-primary-foreground/15" />
<div className="absolute size-40 rounded-full border border-primary-foreground/20" />
{/* eslint-disable-next-line @next/next/no-img-element */}
<img src="/logo.png" alt="ARTEX" width={160} height={160} className="relative brightness-0 invert" />
<picture className="contents">
<source srcSet="/logo.webp" type="image/webp" />
<img src="/logo.png" alt="ARTEX" width={160} height={160} className="relative brightness-0 invert" />
</picture>
</div>
</div>
@@ -44,7 +44,10 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
<SidebarMenuButton asChild>
<Link prefetch={false} href="/function/tasks">
{/* eslint-disable-next-line @next/next/no-img-element */}
<img src="/logo.png" alt="ARTEX" width={40} height={40} className="shrink-0" />
<picture className="contents">
<source srcSet="/logo.webp" type="image/webp" />
<img src="/logo.png" alt="ARTEX" width={40} height={40} className="shrink-0" />
</picture>
<span className="font-semibold text-base">{APP_CONFIG.name}</span>
</Link>
</SidebarMenuButton>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 480 KiB

After

Width:  |  Height:  |  Size: 17 KiB