Skip to content

Commit

Permalink
perf: improve asset loading
Browse files Browse the repository at this point in the history
  • Loading branch information
deansallinen committed Dec 18, 2024
1 parent 69931d2 commit ec7eaa0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
src: url('/fonts/inter/web-latin/Inter-Bold-subset.woff2?v=4.0') format('woff2');
}
</style>
<link rel="preconnect" href="https://assets.wharfkit.com" />
%sveltekit.head%
</head>

Expand Down
16 changes: 5 additions & 11 deletions src/routes/[network]/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,14 @@
// set the flag to prevent banner showing on next load
localStorage.setItem('hide-v1-banner', 'true');
}
// Deduplicate chain logos
let logoSet = Array.from(new Set(chainLogos.values())).map(String);
</script>

<!-- Preload current chain logo, prefetch the rest to avoid future pop-in -->
<!-- Preload current chain logo -->
<svelte:head>
{#each logoSet as logoSrc}
{#if logoSrc === chainLogos.get(String(data.network.chain.id))}
<link rel="preload" href={logoSrc} as="image" type="image/png" />
{:else}
<link rel="prefetch" href={logoSrc} as="image" type="image/png" />
{/if}
{/each}
{#if chainLogos.get(String(data.network.chain.id)) !== undefined}
{@const chainLogo = String(chainLogos.get(String(data.network.chain.id)))}
<link rel="preload" href={chainLogo} as="image" type="image/png" />
{/if}
</svelte:head>

{#if showBanner}
Expand Down

0 comments on commit ec7eaa0

Please sign in to comment.