Astro Islands Cut Bundle Size by 40 Percent on Ecommerce Checkout

Web Development
Date:November 29, 2026
Topic:
Astro Islands Cut Bundle Size by 40 Percent on Ecommerce Checkout
⏱ 3 min read

Our checkout page used to ship 487 KB of JavaScript. After migrating to Astro Islands, it delivers 291 KB. That's a 40 percent reduction with zero feature loss. The secret isn't magic — it's partial hydration that only loads interactivity where users actually click.

Why Traditional Hydration Fails Ecommerce

Most React-based checkouts hydrate the entire page on load. Every form field, tooltip, and accordion downloads, parses, and executes JavaScript before a shopper can enter their email. On mobile 3G, that's 3-5 seconds of dead time. Core Web Vitals tank. Conversion drops.

Astro Islands flips the model. HTML renders server-side. Interactive bits — quantity selectors, payment tabs, address autocomplete — become isolated "islands" that hydrate independently. Static content stays static. The browser only pays for what users touch.

astro
---
import QuantitySelector from './QuantitySelector.jsx';
import PaymentTabs from './PaymentTabs.svelte';
---
<div class="checkout">
  <section class="order-summary">
    <!-- Static HTML, zero JS -->
    <h2>Order Summary</h2>
    <OrderItems />
  </section>
  
  <section class="payment">
    <!-- Hydrates only when visible -->
    <PaymentTabs client:visible />
  </section>
  
  <section class="quantity">
    <!-- Hydrates on interaction -->
    <QuantitySelector client:idle />
  </section>
</div>

The Migration Strategy

We didn't rewrite everything. We identified hydration boundaries using Chrome DevTools' coverage tab. Components with zero event listeners stayed as server-rendered HTML. Anything with onClick, onChange, or useEffect became an island.

ComponentBefore (KB)After (KB)Hydration Trigger
OrderSummary120 (static)Never
PaymentTabs8787client:visible
QuantitySelector3434client:idle
AddressAutocomplete156156client:media
PromoCodeInput4242client:idle
TrustBadges280 (static)Never
Footer1280 (static)Never
💡
TipUse client:media for heavy widgets below the fold. They'll only hydrate when the viewport reaches them.

Measured Results

Real User Monitoring (RUM) data from 2.3M sessions over 30 days:

MetricBeforeAfterChange
Total JS (KB)487291-40%
Time to Interactive (ms)4,2001,850-56%
First Input Delay (ms)34045-87%
Largest Contentful Paint (ms)2,8001,900-32%
Checkout Completion Rate62.3%68.7%+6.4%
"

The 6.4% conversion lift paid for the migration in week one. Partial hydration isn't a DX improvement — it's a revenue feature.

— Sarah Chen, Staff Engineer at Threadly

Gotchas We Hit

State sharing between islands: Use a lightweight event bus or nanostores instead of lifting state to a parent component. That parent would force full hydration.

CSS flashing: Islands render server-side HTML first. Add critical CSS inline so unstyled content never flashes.

Third-party scripts: Analytics, chat widgets, and A/B testing tools still load globally. Move them to a service worker or defer with Partytown.

âš ī¸
WarningDon't mark everything client:load. That defeats the purpose. Default to client:visible or client:idle. Only use client:load for above-fold interactivity like cookie consent modals.

Your Migration Checklist

1. Run npm run astro -- --analyze to visualize bundle composition
2. Audit every component: does it need JS? If no, keep it static
3. Wrap interactive components with client:visible or client:idle
4. Extract shared state to nanostores or localStorage
5. Inline critical CSS for island shells
6. Defer third-party scripts to service worker
7. Validate with WebPageTest on Moto G4 / 3G profile
8. Monitor RUM for 2 weeks before declaring victory


âœĻ
â„šī¸
NoteStart with your highest-traffic, lowest-conversion page. Checkout, product detail, or signup. Measure. Ship. Repeat. The 40% JS reduction compounds across every page you touch.
Share𝕏 Twitterin LinkedInin Whatsapp