From f506a1141676775c7530f6f88bdae699cea90c34 Mon Sep 17 00:00:00 2001 From: Max Nuding Date: Sun, 20 Jul 2025 11:41:16 +0200 Subject: [PATCH] lazy load images only starting with the fifth post --- src/lib/components/AvatarComponent.svelte | 6 ++++-- src/lib/components/PostComponent.svelte | 25 +++++++++++++++++++---- src/routes/+page.svelte | 4 ++-- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/lib/components/AvatarComponent.svelte b/src/lib/components/AvatarComponent.svelte index 980bc7b..04dd0b6 100644 --- a/src/lib/components/AvatarComponent.svelte +++ b/src/lib/components/AvatarComponent.svelte @@ -3,10 +3,12 @@ interface Props { account: Account; + lazyLoadImages: Boolean; } - let { account }: Props = $props(); + let { account, lazyLoadImages = true }: Props = $props(); let avatarDescription: string = $derived(`Avatar for ${account.acct}`); + let loadingProp = $derived(lazyLoadImages ? 'lazy' : 'eager'); let sourceSetHtml: string = $derived.by(() => { // Sort thumbnails by file type. This is important, because the order of the srcset entries matter. // We need the best format to be first @@ -41,7 +43,7 @@ {@html sourceSetHtml} - {avatarDescription} + {avatarDescription}