Skip to content

Commit 4d42a73

Browse files
committed
Patch
1 parent 90f3b65 commit 4d42a73

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

src/layouts/BaseLayout.astro

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ const { title } = Astro.props;
66
<head>
77
<meta charset="utf-8" />
88
<meta name="viewport" content="width=device-width" />
9+
<!-- Browser chrome color: works on Android Chrome + iOS Safari 15+ for address bar -->
910
<meta name="theme-color" content="#29303C" />
11+
<meta name="apple-mobile-web-app-capable" content="yes" />
12+
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
1013
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
1114
<title>{title}</title>
12-
<!-- Preload logo assets so the fallback appears immediately and gears
13-
start decoding before the page finishes rendering everything else -->
15+
<!-- Preload the static logo pieces immediately.
16+
gears.webp is 2MB so we only preload it on desktop (media query). -->
1417
<link rel="preload" as="image" href="/images/logo_fallback.png" />
15-
<link rel="preload" as="image" href="/images/gears.webp" />
1618
<link rel="preload" as="image" href="/images/static.png" />
19+
<link rel="preload" as="image" href="/images/gears.webp" media="(min-width: 1021px)" />
1720
</head>
1821
<body>
1922
<slot />
@@ -44,6 +47,7 @@ const { title } = Astro.props;
4447
display: flex;
4548
justify-content: center;
4649
padding: 20px;
50+
background-color: #29303C;
4751
}
4852

4953
body::before {

src/pages/index.astro

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,22 @@ const paddedStamps = Array(copies).fill(stamps).flat();
1919
<div class="logo-wrap">
2020
<img class="logo-fallback" src="/images/logo_fallback.png" width="823" height="287" alt="Oliver Ohrt logo" />
2121
<div class="logo-composite">
22-
<img src="/images/gears.webp" width="169" height="287" alt=""
22+
<!-- gears.webp is 2MB — skip it on mobile to avoid slow loads. -->
23+
<img id="gears-img" src="" data-src="/images/gears.webp" width="169" height="287" alt=""
2324
onload="this.closest('.logo-wrap').querySelector('.logo-fallback').style.display='none'" />
2425
<img src="/images/static.png" width="654" height="287" alt="" />
2526
</div>
2627
</div>
2728
</div>
29+
<script>
30+
// Only load the 2MB animated gears on desktop
31+
// static fallback PNG which is already loaded and looks the same.
32+
if (window.innerWidth > 1020) {
33+
const img = document.getElementById('gears-img') as HTMLImageElement | null;
34+
if (img) img.src = img.dataset.src!;
35+
}
36+
</script>
37+
2838
<div class="box subheader">
2939
<marquee behavior="scroll" direction="right" style="color:rgb(3, 48, 252); text-shadow: 0 0 6px #ffffff, 0 0 10px #ffffff; font-weight: bold; font-size: 14px;">
3040
Welcome to my site!

0 commit comments

Comments
 (0)