---
title: "A Whole Website in a Single JavaScript File"
description: "A demo multi-page website fits entirely in one JavaScript file and is server-rendered on demand at the edge with Deno."
url: "https://swe.quest/articles/a-whole-website-in-a-single-javascript-file-71d46431d0988f5b"
canonical: "https://deno.com/blog/a-whole-website-in-a-single-js-file"
source: "Deno"
published: "2022-04-05"
difficulty: "medium"
kind: "How-to"
reading_minutes: 2
tags: ["javascript","serverless","cdn-edge","frontend","typescript"]
---

# A Whole Website in a Single JavaScript File

A post on [Deno](https://swe.quest/sources/deno.md), published 2022-04-05, 2 min read, How-to. Original: [https://deno.com/blog/a-whole-website-in-a-single-js-file](https://deno.com/blog/a-whole-website-in-a-single-js-file)

## Summary

A demo multi-page website fits entirely in one JavaScript file and is server-rendered on demand at the edge with Deno. Routing uses a small \`router\` module built on \`URLPattern\`, and JSX is rendered server-side with \`nanossr\`, which styles via twind. Triple-slash reference comments select exactly which TypeScript libs (dom, dom.asynciterable, deno.ns) are loaded. Hosted on Deno Deploy, the site gets a perfect PageSpeed score and is served from 29 data centers over an anycast IP at no cost.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)
- [Serverless](https://swe.quest/tags/serverless.md) (Backend & APIs)
- [CDN & edge](https://swe.quest/tags/cdn-edge.md) (Infrastructure)
- [Frontend](https://swe.quest/tags/frontend.md) (Web & mobile)
- [TypeScript](https://swe.quest/tags/typescript.md) (Languages)

## Prerequisites

- JSX
- TypeScript basics ([easy posts on TypeScript](https://swe.quest/tags/typescript.md?difficulty=easy))

## Keywords

Deno, Deno Deploy, nanossr, twind, URLPattern, JSX

## Related posts

- [Fresh 1.0](https://swe.quest/articles/fresh-1-0-407c9d4b84f51b2c.md): Deno · 2022-06-28 · Medium · 5 min read · Frontend, JavaScript, TypeScript, Web performance, CDN & edge
  Fresh is a full stack web framework for Deno that renders pages just-in-time on the server and ships zero JavaScript to the client by default, using the islands architecture so only explicitly opted-in components are hydrated in the browser.
- [A Whole Website in a Single JavaScript File, cont'd](https://swe.quest/articles/a-whole-website-in-a-single-javascript-file-cont-d-596fba773a32d01c.md): Deno · 2022-09-13 · Medium · 4 min read · JavaScript, Frontend, TypeScript
  A complete bagel-search web app with server-side rendered JSX, dynamic routes and form handling fits in one Deno JavaScript file.
- [Build and Ship Astro Sites with Deno and Deno Deploy](https://swe.quest/articles/build-and-ship-astro-sites-with-deno-and-deno-deploy-3be8936cebaf2b24.md): Deno · 2023-07-21 · Medium · 12 min read · Frontend, Serverless, Deployment, TypeScript
  Astro sites can be built with the Deno runtime and hosted on Deno Deploy in two modes.
- [Build an Astro site with Deno](https://swe.quest/articles/build-an-astro-site-with-deno-cd90d47e8a2fd029.md): Deno · 2024-10-29 · Medium · 4 min read · Frontend, JavaScript, TypeScript
  Deno 2's Node and npm compatibility lets you scaffold and run an Astro project entirely with Deno tooling: \`deno -A npm:create-astro@latest\` to scaffold, \`deno install --allow-scripts\` for dependencies, and \`deno task dev\` to run package.json scripts.
- [Deno 1.35: A fast and convenient way to build web servers](https://swe.quest/articles/deno-1-35-a-fast-and-convenient-way-to-build-web-servers-4272182679c6d67c.md): Deno · 2023-07-05 · Medium · 5 min read · JavaScript, TypeScript, Runtimes & VMs, Performance engineering
  Deno.serve() is now stable, replacing the connection-iterator Deno.serveHttp() pattern with a one-line handler built on web-standard Request and Response objects.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
