Episode 10 game · Vayu · Air

Calm the Thrashing Golem

One click on Kai’s gallery and the page freezes. Feel the golem wake as every offsetWidth read forces a new layout, fix the loop so it reads first and writes after, then prove it in a real browser frame test.

VayuLight work, Kai, done in the right order. Click Grid view and watch what your sizing loop asks of the browser.
10Seal 10
kai.app/gallery
Vayu’s frame watch what one click asked the browser to do
Cards240
Forced layouts0
Click took–

Purple = a layout the browser had to run in the middle of your script.

1 · Feel the freeze

This gallery is real DOM. Kai’s loop measures each card with offsetWidth, then sets its height. Click and count the layouts.

Write, then read = forced layout

offsetWidth after a style change makes the browser lay out the page right now.

Read all, then write all

Collect every measurement first, then apply every change. Layout runs once.

Let CSS measure

aspect-ratio: 4 / 3 sizes the cards with zero JavaScript reads.