UX Improvement Techniques for Enhancing Perceived Speed and Usability in Astro Sites

Published on 📖 5 min read

Balancing “Speed” and “Comfort” in Modern Websites

Website performance cannot be measured solely by page load speed metrics like LCP. What matters is how seamlessly users can navigate through the site and explore information—specifically, the “perceived speed” of transitioning between actions without friction, and the “comfort” of the overall interaction experience.

Astro is a framework excelling at static site generation, achieving remarkable display speeds by aggressively eliminating unnecessary JavaScript. However, standard static sites can suffer from “disruptions” caused by default browser behaviors, such as screen flickering during page transitions or scroll positions being reset.

This article explains concrete implementation approaches to solve these issues while preserving the benefits of static sites and delivering seamless experiences akin to native apps or single-page applications.

Achieving Smooth Screen Transitions with View Transitions API

To eliminate visual disruptions during page transitions, the View Transitions API proves highly effective. This technology connects page transitions with animations, allowing users to continue browsing while maintaining a sense of continuity in the information flow.

In Astro, you can introduce this advanced feature simply by adding a standard provided component to shared areas like layout files.

Visual Continuity and Its Impact on User Experience

In traditional multi-page applications, clicking a link causes the current page to disappear instantly, and the new page is built from scratch. With the View Transitions API, the browser captures the state of both the old and new pages, automatically generating animations such as crossfades.

This gives users the sensation that the page is “transforming” rather than “switching.” By maintaining visual continuity, users can more easily understand where they are within the site, significantly reducing exploration stress.

Browser Compatibility and Fallback Strategy

This feature is natively supported in major browsers. Astro’s implementation includes a mechanism that automatically falls back to standard page transitions for older browsers or specific environments that do not support the API. This enables you to adopt cutting-edge technology while ensuring accessibility is not compromised for any user.

Challenging “Zero Wait Time” with Prefetch

To make screen transition animations even more effective, destination data must be ready instantly. This is where Astro’s Prefetch feature shines.

Mechanism for Anticipating User Actions

Prefetch is a mechanism that loads page data in the background before users actually click a link.

Specifically, it triggers when the mouse cursor hovers over a link or when a link becomes visible within the viewport, leveraging modern browser standard features like the Speculation Rules API to initiate preparatory loading.

The greatest advantage of this approach is that it completes communication during the brief gap between users thinking “I want to click” and actually completing the action. Since the data is already available at the moment of clicking, the perceived load time approaches zero.

Optimized Configuration and Efficient Delivery

Simply enabling this feature in Astro’s configuration file automatically applies it to navigation and article list links across the entire site. It pairs exceptionally well with Astro’s characteristic of serving static HTML files, requiring no complex server-side processing. This allows you to achieve maximum effect while minimizing infrastructure load.

Dynamic Restoration of Scroll State and Loaded Content

For list pages like blogs or news sites, nothing is more frustrating for users than “not being able to return to where they were.” When returning to a list page after reading an article, behaviors such as being reset to the top of the page or losing previously loaded content significantly reduce navigability.

To solve this problem, we build a state preservation mechanism combining browser SessionStorage with Astro’s lifecycle events.

Process for Memorizing State Before Transition

Immediately before a user navigates from a list page to an individual article page, the system temporarily saves the current page state. Specifically, it records the current vertical scroll position (Y coordinate) and the number of articles already loaded via infinite scroll as a single dataset.

The SessionStorage used here remains valid as long as the browser tab is not closed, providing highly stable behavior for “back” and “forward” navigation within the same session.

Seamless Reproduction When Returning to Page

When returning from an article page to the list page, we hook into Astro’s page load events to retrieve the saved data.

  1. Content Reconstruction: Based on the saved number of articles, missing data is immediately loaded.
  2. Scroll Restoration: Once data expansion is complete, the screen automatically moves to the exact scroll position from before the transition.
  3. Cleanup: After restoration is complete, temporary data is cleared to prepare for the next transition.

Through this series of operations, users can “continue reading from where they left off.”

Technical Synergy and Design Philosophy

The three elements introduced above—“View Transitions API,” “Prefetch,” and “State Restoration”—each deliver effects independently, but true UX improvement is realized when they are combined.

Prefetch prepares data instantly, View Transitions API provides smooth visual effects, and State Restoration respects user interaction history. This three-pronged approach enables building modern interaction experiences on top of the solid technical foundation of static site generation.

Considerations for Maintainability and Extensibility

What is important in these implementations is that they rely solely on Astro’s built-in features and standard browser APIs, without depending on heavy external libraries.

This enables flexible responses to future framework updates and browser evolution, keeping the overall codebase lightweight and clean.

Additionally, while this article uses implementation focused on top-page listing as an example, this approach can be applied to any dynamic list display, such as tag-based article lists or search result pages.

UX Improvements Expanding the Possibilities of Static Sites

When building sites with Astro, maintaining high delivery performance through SSG (Static Site Generation) is fundamental. On top of that, layering UX improvements like those described here enables users to feel not just that the site is “fast,” but that it is “pleasant to use.”

Performing meticulous control behind the scenes without making users aware of technical complexity. Such attention to detail enhances site reliability and satisfaction, ultimately leading to delivering content to more readers.

By actively embracing the evolution of web standards, we will continue to enable even better experiences that transcend the boundary between static sites and applications.

Category: Web Dev

Related Posts