DEV Community

Cover image for Dynamic Sites, Statically Hosted, Best for SEO & Performance
pratham patankar
pratham patankar

Posted on Edited on

Dynamic Sites, Statically Hosted, Best for SEO & Performance

Lighthouse performance of website

network request and payload size of website

Why Pure Html?

no framework, no hydration. the browser gets html, parses it, and that's it. since the portfolio is information dense (projects, experience, education, contact, papers), i wanted the content to be in the document itself instead of showing up after some js bundle boots up. crawlers love that, and so do users on slow connections.

"Dynamic" But Static

the site still feels dynamic: there's spa navigation between all the different page routes, so moving around doesn't trigger a full page reload. it's just plain js running on the client, and the server only ever hands out files. no server rendering, nothing to cold start. "dynamic sites, statically hosted" basically.

Content Lives Elsewhere

i didn't want to host articles myself. building a whole blog system just for that would be reinventing the wheel, but worse, and probably with no seo. so i write on dev.to and reddit, and the site pulls that content in. the writing gets distribution and indexing from platforms that already have it, and the portfolio stays lean.

The Build: Bun Standalone Html

this is the part i like the most. bun can bundle a frontend into a single self-contained .html file:

bun build --compile --minify --target=browser ./public/index.html --outdir=dist
Enter fullscreen mode Exit fullscreen mode

it takes the js, css, images and fonts referenced by relative paths and inlines all of it into one file, using plain <script> and <style> tags and base64 data: uris. no archive format, no folder of assets, nothing browser specific. any browser can open it and any server can host it.

that's why the page is basically one request, and why my profile picture shows up in the network tab as a data:image/jpeg entry instead of a separate file.

things to know:

  • anything with an external url (cdn links, absolute urls) is left untouched, only relative paths get inlined, so i keep icons and assets local
  • base64 adds about 33% overhead on top of the raw binary, so big assets will bloat the file
  • code splitting isn't supported in this mode

The Stack

  • html, css, js: that's the whole site
  • bun: dev server with live reload, plus the standalone html build
  • cloudflare workers: serves the static files from the edge, close to wherever the visitor is

The Numbers

portfolio.praxham.workers.dev gets a 98 on lighthouse performance:

metric value
first contentful paint 0.3 s
largest contentful paint 0.3 s
total blocking time 0 ms
speed index 0.3 s
cumulative layout shift 0.087

and the network tab is almost boring:

  • the html document is 67.3 kB and loads in 372 ms
  • the profile picture is inlined as a base64 jpeg, served from memory cache at 0 ms
  • that's it. two entries total.

Why It Scores So High

  • everything is bundled into the one html file, so there are no extra requests to wait on
  • no third party scripts, which is how total blocking time stays at 0 ms
  • icons and images are local, so bun inlines them with everything else

the only number that isn't perfect is layout shift at 0.087. it's still green, but that's where the remaining points are.

Takeaways

  • for a simple content heavy site, you don't need a framework
  • inlining small assets saves requests, but it bloats the html, so it's a tradeoff
  • third party scripts are almost always the biggest performance hit, so i don't ship any
  • writing on platforms that already rank beats rebuilding a blog from scratch
  • static hosting on the edge is fast by default, and you barely have to think about it

if you're building something content heavy and want good SEO, try plain html first. you might not need anything else.

Want One Like This?

If you want something like this for your own idea, reach out to me at hello@madeinvikhroli.com and I'll build it for you. It's a paid service, so tell me what you need and we'll sort out the details.

Top comments (0)