Skip to content

No JavaScript? #3662

@Ionaru

Description

@Ionaru

Hi!

As I was preparing a presentation about Fresh I wanted to demonstrate the following claim on the Fresh homepage:

Fresh routes are dynamically server-rendered Preact components, so there's zero JavaScript shipped to the browser by default.

This claim is repeated in several places, including Fresh's README.md

Zero runtime overhead: no JS is shipped to the client by default.

And I ran into an issue...

Given the following code:

vite.config.ts

import { defineConfig } from "vite";
import { fresh } from "@fresh/plugin-vite";

export default defineConfig({
  plugins: [fresh({
    // https://github.com/denoland/fresh/issues/3476
    serverEntry: "./main.tsx",
  })],
});

main.tsx

import { App, staticFiles } from "fresh";

export const app = new App();

app.use(staticFiles());

app.get("/", (ctx) => {
  const time = new Date().toLocaleString();
  return ctx.render(<p>Freshly server-rendered {time}</p>);
});

Renders the following HTML (line breaks & indentation added for clarity):

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8"/>
  </head>
  <body>
    <p>Freshly server-rendered 05/01/2026, 20:56:39</p>
    <script type="module" nonce="944c3613b7b1427d9c781403e6154b9b">import { boot } from "/assets/client-entry-Cz-rWMt7.js";boot({},"[[]]");</script>
  </body>
</html>
Image

As you can see, it does load JavaScript! A whopping 35kb of it. Can't be Preact, that's only 3kb according to their website. 🤔

What JavaScript is Fresh loading, and why does it load any JavaScript for this extremely simple page?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions