#The Hidden Cost of Client JavaScript
On high-end desktop workstations with fiber internet, shipping 2MB of JavaScript feels indistinguishable from a static page. But for real-world users on mid-tier mobile processors, JavaScript is the single most expensive asset you can deliver to a browser:
- Network Transfer: Download over variable cellular networks.
- V8 Parser & Bytecode Compiler: Decompressing and parsing JS abstract syntax trees.
- Execution & Hydration: CPU execution lock while hydrating React component trees.
- Garbage Collection (GC): Continuous heap allocation and pauses.
Standard SPA / Heavy SSR:
[HTML Download] ──► [Bundle JS Download (2.5MB)] ──► [Parse & Compile (350ms)] ──► [Hydration (500ms)] ──► Interactive
Server Component (RSC) Architecture:
[Stream HTML with Inlined Critical CSS] ──► [First Contentful Paint (80ms)] ──► [Interactive Immediately!]
#Zero Client Bundle Syntax Highlighting
In technical blogs, syntax highlighters (Prism.js, Highlight.js) traditionally required clients to download grammar grammars for 50 languages, adding 200KB-800KB of parser code to the client bundle.
With Shiki and Server Components, syntax highlighting happens exclusively on the Node server during SSR or static build time:
// Pure Server Component - 0 bytes sent to browser!
import { codeToHtml } from 'shiki';
interface CodeBlockProps {
code: string;
lang: string;
}
export async function CodeBlock({ code, lang }: CodeBlockProps) {
const html = await codeToHtml(code, {
lang,
theme: 'github-dark-default',
});
return (
<div
className="rounded-xl overflow-hidden my-6 border border-slate-800 text-sm leading-relaxed"
dangerouslySetInnerHTML={{ __html: html }}
/>
);
}
The browser receives pure semantic HTML elements (<pre><code><span style="color:#...">) with zero JavaScript runtime overhead!
#The Islands Architecture: Client Only When Interactivity Is Required
Reserve the "use client" directive solely for localized interactive elements:
- Copying a snippet to clipboard (
navigator.clipboard.writeText) - Filter search inputs with client-side debounce
- Mobile drawer toggling
Everything else — Article content, Table of Contents, Author Bios, Comments lists, and Meta tags — should remain 100% Server Components.