A Andres Hernandez
Astro HTML CSS

Optimizing Astro Performance: Custom LogoWalls and Font Loading

In the ongoing development of the Astro-portfolio project, I recently focused on refining the visual consistency and loading performance of the site. Specifically, I set out to improve the custom LogoWall component and ensure that typography renders without layout shifts by implementing local font preloading.

The Challenge: Layout Shifts and Component Bloat

Previously, our logo rendering relied on external dependencies that introduced unnecessary network requests, while font loading was handled via standard browser defaults. This resulted in two main issues:

  1. Unstable Visuals: Components were jittering as external assets loaded asynchronously.
  2. Performance Drag: External font calls delayed the first contentful paint, impacting our Core Web Vitals.

Implementation Strategy

To address this, I shifted toward a self-hosted strategy. By moving fonts into the local assets pipeline, I could leverage Astro's efficient bundling capabilities. I also refactored the LogoWall to be more robust, allowing for cleaner markup and faster DOM reconciliation.

---
import { getImage } from 'astro:assets';
// Preload local font in the head
---
<link rel="preload" href="/fonts/brand-font.woff2" as="font" type="font/woff2" crossorigin />

<div class="logo-wall">
  {logos.map(logo => (
    <img src={logo.src} alt="Partner Logo" loading="lazy" />
  ))}
</div>

This approach ensures the font is prioritized by the browser immediately, preventing the "flash of unstyled text." The loading="lazy" attribute on the LogoWall images further ensures that our heavy visual assets don't compete with critical path resources.

The Takeaway

By moving away from third-party font hosting and tightening our component architecture, we've achieved a snappier, more professional-feeling site. Modern web development is often about knowing when to stop relying on external services and start taking ownership of your asset pipeline. Start small: audit your fonts, and if they aren't self-hosted, that is your next performance win.


Generated with Gitvlg.com

Optimizing Astro Performance: Custom LogoWalls and Font Loading
Andres Hernandez

Andres Hernandez

Author

Share: