The sky at the top of the home page is real: what's above you right now, worked out in your browser and drawn entirely in text. This page explains how, and grows with the site.
The sky is real
Every star brighter than magnitude 5.5 is up there, which is close to everything you could see with your own eyes from a properly dark spot. Each one is where it should be for the current time, along with the Sun, the Moon in its real phase, and the planets.
To get there, your browser works out the sidereal time, shifts each star's catalogue position to today's date to allow for precession, and calculates where the Sun, Moon and planets are. I checked the results against Astronomy Engine, an established astronomy library: the Sun is within 0.01°, the planets within 0.2° and the Moon within 0.35°. Smaller effects, such as nutation and refraction, are left out, since each moves things by less than a character.
It never asks for your location. It picks a nearby city from your time zone instead, which is close enough for the sky, hence "London (or near it)".
Hover over a star, or tap it on a phone, to see what it is and when the light reaching you set off. The Milky Way is real too: a brightness map from NASA.
The black hole is the one thing up there that isn't real.
How it's drawn
Everything in the sky is a character on a grid, drawn onto a canvas in the same monospace font as the rest of the site. The font is Monaspace Neon, cut down to just the characters the site uses, which brings it to 19.5 KB.
Keeping it fast
Speed is the point of this site, so the sky has to earn its place:
- It loads after the page is ready, so the text never waits for it.
- The heavy maths reruns only when the sky has turned enough to notice, about every five seconds. In between, only the characters that change are redrawn.
- Animation runs on a fixed step, so it looks the same at 60 or 120 frames a second.
- It pauses when you scroll past it or switch tabs, holds still if your device asks for reduced motion, and simplifies itself if your device is struggling.
- If anything goes wrong, the sky quietly disappears and the page carries on without it.
The engine is about 15 KB compressed, plus 20 KB of star data, and the star names load only when you first hover. On a budget Android phone it holds 60 frames a second, and the home page scores 100 in all four Lighthouse categories.
Play with it
There's a console. Quake players will know which key opens it; everyone else can press the >_ under my name. Type help for the commands. goto capetown shows the sky over somewhere else, time 1969-07-20 20:17 any moment from 1800 to 2050, timescale 1h speeds time up, and noclip lets you pick up the black hole and move it.
The sky also has a page of its own, full screen, and its address always links to the sky you're looking at, so you can send someone the sky over Cape Town on the night of the Moon landing.
The rest of the site
Next.js and React, with every page built ahead of time as static HTML. TypeScript, Tailwind CSS, and MDX for the writing. Every change is checked in CI: types, lint, tests, a size budget for the JavaScript, and Lighthouse. The analytics are cookieless.
Still to come
Satellites and the next pass of the International Space Station, and goto for any place on Earth, not just the ones it knows by name.
Credits
- Stars: the HYG database v4.4, CC BY-SA 4.0.
- Milky Way: NASA's Deep Star Maps 2020, from the NASA/Goddard Space Flight Center Scientific Visualization Studio, using Gaia, Hipparcos and Tycho data.
- Font: Monaspace by GitHub Next, under the SIL Open Font License, renamed for this site as the licence asks.
- Positions checked against Astronomy Engine by Don Cross.