Why a loader costs little at run time, where the bake happens, what a track weighs, and which renderer to pick for large fields or many loaders.
Engine · 2 min read
The expensive work happens once, before the loop starts. After that, every frame only reads bytes. This page shows where the time goes.
Bake once, read every frame
The engine runs a scene once per loop length, not once per frame. It samples every dot 30 times a second and stores each value as one byte. A renderer then reads the byte for each dot at the current time.
A track is small. The orbit pattern on a 9 × 9 square has 81 dots and a 1.4s loop: 42 frames. Its light is 81 × 42 = 3,402 bytes.
- Off the page. One worker thread does every bake. If the worker cannot start, such as under a Content Security Policy without
worker-src 'self', the engine bakes on the page in idle time, in short slices. - Shared. Two loaders with the same pattern and lattice share one bake.
- First frame first. The server draws the first frame from a single sample of each dot. So the loader shows at once, and the loop starts when the bake is done.
What makes a bake cost more
The bake cost is the number of dots, times the frames of one loop, times the work of each node. These raise it:
- More dots. A large
look.grid, or your own grid. A named layout picks the grid fromsize, up to the scene'smost. - A longer loop. Each second adds 30 frames.
- Input steps. A scene with
input: 33bakes 33 loops, one for each step. - Copies and samples.
repeatandparticlesrun their node once for each copy.trailruns its field once for each sample. - A new scene object. The engine knows a scene by its object. Define your scene outside the component, so it bakes once.
Only what is seen
A loader runs only while it is on screen and the tab is visible. A page of 50 loaders costs only the ones in view.
Pick a renderer
All renderers read the same track. Pick by the size of the matrix and the number on the page.
| You have | Use | Why |
|---|---|---|
| A few loaders next to text | Canvas (default) | One small canvas each, drawn from shared sprites |
| Loaders that must move while the main thread is busy | DOM (dot-matrix-dom) | The compositor runs their Web Animations |
| A large field or many loaders on one page | WebGL (dot-matrix-webgl) | The GPU draws every dot, on one shared context |
Our home page's backdrop has 5,520 dots. On the canvas renderer it took 11.1ms of main thread a frame and dropped frames. On WebGL it took 0.44ms a frame, at 120 frames a second.
Measure your own
Run a loader in your page, then record a performance trace in your browser's dev tools. Look at the scripting time per frame. A few canvas loaders should stay well under a millisecond.