Ray's Knowledge Base
Unlock

Code that site.js runs once at page load stays empty on a protected lesson

PitfallVerified 1 Oct 2026Holds project: rkb
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

A value that site.js fills in once at load, such as a relative age computed from data-date, is empty on a protected lesson.

Cause#

A protected lesson page is decrypted after the page has loaded, so the one-time code ran before the content existed.

Fix#

Put such code in enhance(), which runs again after an unlock. Test a protected page with SITE_PASSWORD=<16+ characters> rkb site serve.

Evidence#

Observer note of 2026-10-01. It names enhance() and the serve command; it shows no output.

Also found by searching

  • relative age is empty on a protected lesson page
  • site.js code does not run on a protected lesson after unlock
  • how do I test a protected page with rkb site serve