# Fresh

Fresh scores 7 of 28 points on 14 speed features: 2/14 on first-paint levers and 5/14 on other features. Rank 22 of 23. Labels: 2 1st-party, 0 Experimental, 3 Third-party, 9 Manual.

- Version checked: Fresh 2.3.3 (jsr:@fresh/core, JSR latest; Deno; docs at usefresh.dev)
- Performance guide: [Islands | Fresh docs](https://fresh.deno.dev/docs/concepts/islands)
- Issue tracker: https://github.com/freshframework/fresh/issues
- Books demo port: [fresh-books](https://github.com/MaxwellCohen/fresh-books)

## Summary

| Feature | Group | Label | Points |
| --- | --- | --- | --- |
| [Production CSS inlining](https://framework-compare.vercel.app/features/css-inlining.md) | First-paint levers | Manual | 0 |
| [Font optimization](https://framework-compare.vercel.app/features/font-optimization.md) | First-paint levers | Third-party | 1 |
| [Image pipeline](https://framework-compare.vercel.app/features/image-pipeline.md) | First-paint levers | Third-party | 1 |
| [Data/HTML caching](https://framework-compare.vercel.app/features/caching.md) | First-paint levers | Manual | 0 |
| [Route prefetching](https://framework-compare.vercel.app/features/route-prefetching.md) | First-paint levers | Manual | 0 |
| [Streaming SSR](https://framework-compare.vercel.app/features/streaming-ssr.md) | First-paint levers | Manual | 0 |
| [Early Hints / preload headers](https://framework-compare.vercel.app/features/early-hints.md) | First-paint levers | Manual | 0 |
| [Islands / partial hydration / lazy slices](https://framework-compare.vercel.app/features/islands.md) | Other features | 1st-party | 2 |
| [Per-route render modes](https://framework-compare.vercel.app/features/render-modes.md) | Other features | Manual | 0 |
| [Fine-grained client reactivity](https://framework-compare.vercel.app/features/reactivity.md) | Other features | 1st-party | 2 |
| [Built-in bundle analysis](https://framework-compare.vercel.app/features/bundle-analysis.md) | Other features | Third-party | 1 |
| [Third-party script strategies](https://framework-compare.vercel.app/features/third-party-scripts.md) | Other features | Manual | 0 |
| [Portable multi-host deployment](https://framework-compare.vercel.app/features/multi-host-deployment.md) | Other features | Manual | 0 |
| [Service worker / offline support](https://framework-compare.vercel.app/features/service-worker.md) | Other features | Manual | 0 |

## First-paint levers

### Production CSS inlining

Label: **Manual** (0 of 2 points).

No first-party CSS inlining documented. Vite bundles CSS imported from `client.ts`; a per-route `css` export adds stylesheets. A Vite `?inline` import would be hand-wired (not found in the Fresh docs). ([vite](https://usefresh.dev/docs/advanced/vite), [file-routing](https://usefresh.dev/docs/concepts/file-routing))

Example of building it yourself:

You import the stylesheet with Vite's `?inline` suffix in `_app.tsx` and render it in a `<style>` tag. Drop the import from `client.ts` so Vite stops adding the `<link>`.

```tsx
// routes/_app.tsx
import globalCss from "../assets/global.css?inline";
import { define } from "../utils.ts";

export default define.page(function App({ Component }) {
  return (
    <html lang="en">
      <head>
        <meta charset="utf-8" />
        {/* _app.tsx is server-only, so the CSS string never reaches an island bundle */}
        <style dangerouslySetInnerHTML={{ __html: globalCss }} />
        {/* … */}
      </head>
      <body f-client-nav>{/* … */}</body>
    </html>
  );
});

// client.ts
// import "./assets/global.css";  ← removed, or the <link> comes back
```

Source: [Vite: disabling CSS injection](https://vite.dev/guide/features#disabling-css-injection-into-the-page)

### Font optimization

Label: **Third-party** (1 of 2 points).

No first-party font handling documented; fonts appear only as files in `static/` referenced by URL. The third-party route is [Fontsource](https://fontsource.org) packages, which the Fresh docs do not mention. ([static-files](https://usefresh.dev/docs/concepts/static-files))

Example of building it yourself:

The Books port self-hosts Geist with Fontsource packages mapped in `deno.json`. The CSS `@import` brings in the `@font-face` rules, and Vite bundles the font files when `client.ts` imports the stylesheet.

```jsonc
// deno.json
"imports": {
  "@fontsource-variable/geist": "npm:@fontsource-variable/geist@^5.3.0"
}
```

```css
/* assets/global.css (imported from client.ts) */
@import '@fontsource-variable/geist';
@import 'tailwindcss';

@theme {
  --font-sans: 'Geist Variable', ui-sans-serif, system-ui, sans-serif;
}
```

Source: [Fontsource: Install](https://fontsource.org/docs/getting-started/install)

### Image pipeline

Label: **Third-party** (1 of 2 points).

The docs say there is no built-in optimization pipeline and suggest `vite-imagetools` or a CDN. Fresh adds long-lived cache headers to `src`/`srcset` (opt out with `data-fresh-disable-lock`); `asset()` / `assetSrcSet()` exist in `fresh/runtime`. ([static-files](https://usefresh.dev/docs/concepts/static-files), [api-reference](https://usefresh.dev/docs/advanced/api-reference))

Example of building it yourself:

Fresh 2 builds with Vite, so `vite-imagetools` resizes and converts images at build time. The query string on the import picks widths and format, and `as=srcset` returns a ready `srcset` string.

```ts
// vite.config.ts
import { defineConfig } from "vite";
import { fresh } from "@fresh/plugin-vite";
import { imagetools } from "vite-imagetools";

export default defineConfig({
  plugins: [fresh(), imagetools()],
});
```

```tsx
// routes/about.tsx
import heroAvif from "../static/hero.jpg?format=avif&w=800";
import heroSrcset from "../static/hero.jpg?w=400;800;1200&format=webp&as=srcset";

export default function About() {
  return <img src={heroAvif} srcset={heroSrcset} sizes="100vw" alt="Shelves of books" width={800} />;
}
```

Source: [Fresh: Static files](https://usefresh.dev/docs/concepts/static-files)

Art direction with `<picture>` (Manual, not scored):

No first-party `<picture>` component documented; the docs point to `vite-imagetools` or a CDN, with markup hand-written. ([static-files](https://usefresh.dev/docs/concepts/static-files))

You write the `<picture>` markup in a Preact component and put each pre-encoded format and crop in `static/` yourself.

```tsx
// components/Hero.tsx
export function Hero() {
  return (
    <picture>
      <source media="(min-width: 1000px)" type="image/avif" srcset="/hero-wide.avif" />
      <source media="(min-width: 1000px)" srcset="/hero-wide.jpg" />
      <source type="image/avif" srcset="/hero-tall.avif" />
      <img
        src="/hero-tall.jpg"
        alt="Shelves of books"
        width={750}
        height={1334}
        fetchPriority="high"
        decoding="async"
      />
    </picture>
  );
}
```

Source: [Fresh static files](https://usefresh.dev/docs/concepts/static-files)

### Data/HTML caching

Label: **Manual** (0 of 2 points).

No first-party cache documented; set `Cache-Control` by hand via `page(data, { headers })`. Build-time prerender exists only as an open, unmerged PR, not in the docs and not credited. ([data-fetching](https://usefresh.dev/docs/concepts/data-fetching), [3766](https://github.com/freshframework/fresh/pull/3766))

Example of building it yourself:

You wrap each query in a TTL cache backed by a host store, and set the HTML Cache-Control in app middleware. This comes from the port.

```ts
// lib/catalog-cache.server.ts
export function withTtlCache<Args extends unknown[], Result>(
  name: string,
  fn: (...args: Args) => Promise<Result>,
): (...args: Args) => Promise<Result> {
  // in-memory Map → Workers KV / Vercel getCache / Netlify Blobs → fn()
  return (...args: Args) => cacheLifeHours(`${name}:${JSON.stringify(args)}`, () => fn(...args))
}

// features/book/book-queries.server.ts
export const getBooksPage = withTtlCache('getBooksPage', getBooksPageUncached)

// main.ts
app.use(async (ctx) => {
  const res = await ctx.next();
  if (!res.headers.get("content-type")?.includes("text/html")) return res;
  const headers = new Headers(res.headers);
  headers.set("Cache-Control", hostDocumentCacheControl());
  return new Response(res.body, { status: res.status, statusText: res.statusText, headers });
});
```

Source: [Fresh data fetching](https://usefresh.dev/docs/concepts/data-fetching)

### Route prefetching

Label: **Manual** (0 of 2 points).

No first-party prefetch documented; partials (`f-client-nav`, `f-partial`) fetch on click only. ([partials](https://usefresh.dev/docs/advanced/partials))

Example of building it yourself:

Add a Speculation Rules block to `_app.tsx`. Supporting browsers prefetch same-origin pages on hover, and other browsers ignore it. The prefetch only helps full-page navigations, so it does not speed up links that use Fresh partials (`f-client-nav`).

```tsx
// routes/_app.tsx
const speculationRules = JSON.stringify({
  prefetch: [{
    where: { and: [
      { href_matches: "/*" },
      { not: { selector_matches: "[rel~=nofollow]" } },
    ] },
    eagerness: "moderate",
  }],
});

// … inside <head>:
<script type="speculationrules" dangerouslySetInnerHTML={{ __html: speculationRules }} />
```

Source: [MDN: speculationrules](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/speculationrules)

### Streaming SSR

Label: **Manual** (0 of 2 points).

No streamed page rendering documented. The docs show a `ReadableStream` returned from an API handler only, and describe no way to flush part of a page early. ([common-patterns](https://usefresh.dev/docs/examples/common-patterns), [data-fetching](https://usefresh.dev/docs/concepts/data-fetching))

Example of building it yourself:

Write the route handler yourself and return a `ReadableStream` of HTML. The shell and a placeholder go out first. When the query resolves, the handler sends the rendered grid and a small script that swaps it in. This page skips Fresh's layouts and islands.

```tsx
// routes/books.tsx
import { define } from "@/utils.ts";
import { renderToString } from "preact-render-to-string";

export const handler = define.handlers({
  GET() {
    const enc = new TextEncoder();
    const body = new ReadableStream({
      async start(controller) {
        controller.enqueue(enc.encode(
          `<!doctype html><html><head><link rel="stylesheet" href="/styles.css"></head>` +
          `<body><main id="grid">Loading…</main>`,
        ));
        const books = await getBooks();
        controller.enqueue(enc.encode(
          `<template id="grid-html">${renderToString(<BookGrid books={books} />)}</template>` +
          `<script>document.getElementById("grid").replaceWith(document.getElementById("grid-html").content)</script></body></html>`,
        ));
        controller.close();
      },
    });
    return new Response(body, { headers: { "Content-Type": "text/html; charset=utf-8" } });
  },
});
```

Source: [Fresh: Common patterns](https://usefresh.dev/docs/examples/common-patterns)

### Early Hints / preload headers

Label: **Manual** (0 of 2 points).

No first-party preload `Link` headers or 103 Early Hints documented. Set a `Link` header by hand through `page(data, { headers })` or a middleware. ([data-fetching](https://usefresh.dev/docs/concepts/data-fetching))

Example of building it yourself:

Set a `Link` header on HTML responses in an app middleware. This one preconnects to the font host. To preload a built file with a hashed name, read its URL from the Vite manifest.

```ts
// main.ts
const LINK = '<https://fonts.gstatic.com>; rel=preconnect; crossorigin';

app.use(async (ctx) => {
  const res = await ctx.next();
  if (res.headers.get('content-type')?.includes('text/html')) res.headers.append('Link', LINK);
  return res;
});
```

Source: [Fresh middleware](https://usefresh.dev/docs/concepts/middleware)

## Other features

### Islands / partial hydration / lazy slices

Label: **1st-party** (2 of 2 points).

Islands are the core model: only island JS ships and bundles are code-split; files live in `islands/` or `(_islands)`; props must be serializable. No lazy/idle/visible hydration timing is documented; Preact `lazy()` + `<Suspense>` is documented for code-splitting an island. ([islands](https://usefresh.dev/docs/concepts/islands), [architecture](https://usefresh.dev/docs/concepts/architecture), [common-patterns](https://usefresh.dev/docs/examples/common-patterns))

Example of building it yourself:

Any component in `islands/` ships JS; everything else renders to HTML only. In the Books port the layout is server-only, and just the search box and the mobile drawer hydrate.

```tsx
// routes/_layout.tsx
import BookSearch from '@/islands/BookSearch.tsx';
import MobileSidebar from '@/islands/MobileSidebar.tsx';
import MobileSidebarTrigger from '@/islands/MobileSidebarTrigger.tsx';
import { define } from '../utils.ts';

export default define.layout(function Layout({ Component, url }) {
  const current = searchParamsFromUrl(url.searchParams);
  return (
    <>
      <MobileSidebar pathname={url.pathname}>
        {/* server-rendered children passed into an island */}
        <BookSidebar current={current} idPrefix="mobile" mobile />
      </MobileSidebar>
      <header>
        <MobileSidebarTrigger />
        <BookSearch current={current} />
      </header>
      <main><Component /></main>
    </>
  );
});
```

Source: [Fresh: Islands](https://usefresh.dev/docs/concepts/islands)

### Per-route render modes

Label: **Manual** (0 of 2 points).

Pages render to HTML on the server; no per-route prerender/SPA/ISR option is documented (`RouteConfig` covers `routeOverride`, `skipAppWrapper`, `skipInheritedLayouts`, `csp` and `methods`; none selects a render mode). No first-party per-route render mode documented. ([architecture](https://usefresh.dev/docs/concepts/architecture), [routing](https://usefresh.dev/docs/concepts/routing), [file-routing](https://usefresh.dev/docs/concepts/file-routing))

Example of building it yourself:

Every route still renders on the server. You pick a mode per route with CDN Cache-Control headers in app middleware, adapting the port's `main.ts` middleware.

```ts
// main.ts
const modes: Record<string, string> = {
  "/about": "public, s-maxage=31536000",                    // "static": cached until redeploy
  "/": "public, s-maxage=60, stale-while-revalidate=86400", // "ISR": revalidate each minute
};

app.use(async (ctx) => {
  const res = await ctx.next();
  if (!res.headers.get("content-type")?.includes("text/html")) return res;
  const headers = new Headers(res.headers);
  headers.set("Cache-Control", modes[ctx.url.pathname] ?? "private, no-store"); // SSR
  return new Response(res.body, { status: res.status, statusText: res.statusText, headers });
});

app.fsRoutes();
```

Source: [Fresh data fetching (response headers)](https://usefresh.dev/docs/concepts/data-fetching)

### Fine-grained client reactivity

Label: **1st-party** (2 of 2 points).

Preact signals (`useSignal` from `@preact/signals`, a dependency of `@fresh/core` and part of the `@fresh/init` scaffold). Fresh serializes signal props so islands share state. ([signals](https://usefresh.dev/docs/concepts/signals), [sharing-state-between-islands](https://usefresh.dev/docs/examples/sharing-state-between-islands))

Example of building it yourself:

Preact signals. In the Books port, one module-level signal is shared by two islands: the trigger sets it and the drawer re-renders when it changes.

```ts
// lib/catalog-nav.ts
import { signal } from '@preact/signals';
export const mobileSidebarOpen = signal(false);
```

```tsx
// islands/MobileSidebarTrigger.tsx
import { mobileSidebarOpen } from '@/lib/catalog-nav.ts';

export default function MobileSidebarTrigger() {
  return <button aria-label="Open filters" onClick={() => (mobileSidebarOpen.value = true)}>Filters</button>;
}

// islands/MobileSidebar.tsx
export default function MobileSidebar({ children }: { children?: ComponentChildren }) {
  const isOpen = mobileSidebarOpen.value;
  return <aside hidden={!isOpen}>{children}</aside>;
}
```

Source: [Fresh: Signals](https://usefresh.dev/docs/concepts/signals)

### Built-in bundle analysis

Label: **Third-party** (1 of 2 points).

No first-party analyzer documented; the Vite page mentions only `vite-plugin-inspect` as a debugging aid. ([vite](https://usefresh.dev/docs/advanced/vite))

Example of building it yourself:

Fresh has no analyzer. The Vite page suggests `vite-plugin-inspect` for looking at transforms during dev; for bundle sizes, add `rollup-plugin-visualizer` and run `deno task build`.

```ts
// vite.config.ts
import { defineConfig } from "vite";
import { fresh } from "@fresh/plugin-vite";
import inspect from "vite-plugin-inspect";
import { visualizer } from "rollup-plugin-visualizer";

export default defineConfig({
  plugins: [
    fresh(),
    inspect(), // dev UI at /__inspect
    visualizer({ filename: "stats.html", gzipSize: true }),
  ],
});
```

Source: [Fresh: Vite](https://usefresh.dev/docs/advanced/vite)

### Third-party script strategies

Label: **Manual** (0 of 2 points).

No first-party script primitive documented; the head page lists `<script>` with no loading-strategy guidance. ([head](https://usefresh.dev/docs/advanced/head))

Example of building it yourself:

You write the loading strategy into `<head>` in `_app.tsx`. Use `async` or `defer` on the tag, or inject it at idle time with an inline script, as the port does for its theme script.

```tsx
// routes/_app.tsx
const loadChatWhenIdle = `(window.requestIdleCallback||setTimeout)(function(){
  var s=document.createElement("script");s.src="https://widget.example.com/chat.js";s.async=true;
  document.head.appendChild(s);});`;

export default define.page(function App({ Component }) {
  return (
    <html lang="en">
      <head>
        {/* … */}
        <script async src="https://analytics.example.com/script.js" />      {/* parallel, non-blocking */}
        <script dangerouslySetInnerHTML={{ __html: loadChatWhenIdle }} />   {/* after load, at idle */}
      </head>
      {/* <head> sits outside <Partial>, so f-client-nav does not re-run these */}
      <body f-client-nav>{/* … */}</body>
    </html>
  );
});
```

Source: [Fresh head](https://usefresh.dev/docs/advanced/head)

### Portable multi-host deployment

Label: **Manual** (0 of 2 points).

Documented: Deno Deploy, `deno compile`, Docker, and Cloudflare Workers (via `@cloudflare/vite-plugin` and a hand-written `server.js`; stability not stated). Node, Vercel, and Netlify are not documented; no official guide was found. ([deployment](https://usefresh.dev/docs/deployment), [cloudflare-workers](https://usefresh.dev/docs/deployment/cloudflare-workers), [docker](https://usefresh.dev/docs/deployment/docker), [deno-deploy](https://usefresh.dev/docs/deployment/deno-deploy))

Example of building it yourself:

You write a post-build script that wraps `_fresh/server.js` in each host's entry shape. This comes from the port: an edge function for Netlify, and a Node handler plus Build Output API config for Vercel.

```js
// scripts/netlify-edge.mjs
import server from "../_fresh/server.js";
export default (request) => server.fetch(request);

// scripts/adapt.mjs (runs after `vite build`; host picked by NETLIFY=1 | VERCEL=1)
if (host === "vercel") {
  await build({ ...common, entryPoints: ["scripts/vercel-handler.mjs"],
    outfile: `${out}/functions/index.func/index.mjs`, platform: "node", target: "node24" });
  await Deno.writeTextFile(`${out}/functions/index.func/.vc-config.json`, JSON.stringify({
    runtime: "nodejs24.x", handler: "index.mjs", launcherType: "Nodejs", supportsResponseStreaming: true,
  }));
  // … copy _fresh/client to static/, write config.json routes
} else if (host === "netlify") {
  await build({ ...common, entryPoints: ["scripts/netlify-edge.mjs"],
    outfile: "netlify/edge-functions/fresh.js", platform: "neutral", external: ["node:*"] });
}
```

Source: [Fresh deployment](https://usefresh.dev/docs/deployment)

### Service worker / offline support

Label: **Manual** (0 of 2 points).

No service worker support documented. Put a hand-written worker in `static/` and register it from an island. ([static-files](https://usefresh.dev/docs/concepts/static-files))

Example of building it yourself:

Put a hand-written worker in `static/` and register it with an inline script in the app wrapper.

```js
// static/sw.js
const CACHE = 'books-v1'; // change the name on each deploy

self.addEventListener('activate', (event) => {
  event.waitUntil(
    caches.keys().then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))),
  );
});

self.addEventListener('fetch', (event) => {
  const { request } = event;
  if (request.method !== 'GET' || new URL(request.url).origin !== location.origin) return;
  // Network first, so pages stay current. The cached copy answers when offline.
  event.respondWith(
    fetch(request)
      .then((response) => {
        const copy = response.clone();
        caches.open(CACHE).then((cache) => cache.put(request, copy));
        return response;
      })
      .catch(() => caches.match(request)),
  );
});
```

```tsx
// routes/_app.tsx
const swScript = `if('serviceWorker' in navigator)addEventListener('load',function(){navigator.serviceWorker.register('/sw.js')});`;
// … in <head>
        <script dangerouslySetInnerHTML={{ __html: swScript }} />
```

Source: [Using Service Workers (MDN)](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers) · [Fresh static files](https://usefresh.dev/docs/concepts/static-files)

## Other performance features

- View Transitions via `f-view-transition` with `f-client-nav`, no polyfill. ([view-transitions](https://usefresh.dev/docs/advanced/view-transitions))
- Built-in OpenTelemetry support. ([introduction](https://usefresh.dev/docs/introduction))
- Streaming handler and `Server-Timing` middleware examples. ([common-patterns](https://usefresh.dev/docs/examples/common-patterns))
- Vite-hashed assets; `asset()` one-year cache lifetime. ([static-files](https://usefresh.dev/docs/concepts/static-files))

## Deployments of the Books demo

| Branch | Note | Vercel | Netlify | Cloudflare |
| --- | --- | --- | --- | --- |
| `main` | vibe port | https://fresh-books.vercel.app | https://fresh-books.netlify.app | https://fresh-books.to-email-max.workers.dev |
| `optimized` | cache + fonts | https://fresh-books-optimized-seven.vercel.app | https://fresh-books-max-optimized.netlify.app | https://fresh-books-optimized.to-email-max.workers.dev |

## Benchmark, 2026-11-28

Tool: PageSpeed Insights v5 (Lighthouse lab run), mobile strategy. 3 measured runs per deployment, median reported; cold runs are left out of the median when a warm run exists. Each build's figure is the average of its hosts' medians (vercel, netlify, cloudflare). Pages measured: book list (/) and one book (/10145787). Times are lab values from one run on 2026-11-28. FCP is the Lighthouse estimate for simulated Slow 4G; Raw FCP, where shown, is the first paint in the real, unthrottled load that estimate is built from. Builds in the same FCP band (https://framework-compare.vercel.app/measured.md) are a tie, so read "fastest first" as band order.

| Page | Build | Branch | Hosts | Performance | FCP | Raw FCP | LCP | TBT | CLS |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| book list (/) | baseline | `main` | cloudflare, netlify, vercel | 84 | 1.51 s | 0.95 s | 4.25 s | 0 ms | 0.000 |
| book list (/) | optimized | `optimized` | cloudflare, netlify, vercel | 90 | 0.92 s | 0.99 s | 3.60 s | 0 ms | 0.000 |
| one book (/10145787) | baseline | `main` | cloudflare, netlify, vercel | 97 | 1.51 s | 0.31 s | 2.49 s | 0 ms | 0.000 |
| one book (/10145787) | optimized | `optimized` | cloudflare, netlify, vercel | 100 | 0.87 s | 0.63 s | 1.81 s | 0 ms | 0.000 |

Full run: https://framework-compare.vercel.app/benchmark.md

---

HTML version: https://framework-compare.vercel.app/frameworks/fresh · All pages: https://framework-compare.vercel.app/llms.txt · Data: https://framework-compare.vercel.app/api/index.json
