Skip to content

Commit 242f0c5

Browse files
sametbasbugclaude
andcommitted
Budget the CSS a browser downloads, not the file on disk
The raw-byte budget failed on the token refactor: 71,492 bytes before, 78,377 after. But measured on the same two builds, gzip went 13,366 -> 13,125 and brotli 11,417 -> 11,242. Hundreds of repetitions of var(--space-8) compress better than seventy distinct arbitrary values, so the change made the transferred stylesheet smaller while making the file bigger. Raw bytes were never what ships -- Cloudflare serves this compressed. So gzip becomes the real budget and gets tighter than the size it was already passing at: 14,000, down from 16,000. The raw check stays as a backstop rather than the headline number, for the case a stylesheet balloons through copy-paste yet still compresses well. Its ceiling moves to 88,000 to sit above what token references legitimately cost. Loosening a threshold that my own change tripped deserves the numbers in writing, which is why they are in the comment. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 1666c01 commit 242f0c5

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

‎scripts/orbit-site-tests.mjs‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,21 @@ for (const post of publicPosts) {
296296
}
297297
}
298298

299+
/*
300+
* CSS bütçesi iki eşikli, çünkü ham boyut kullanıcıya giden şey değil.
301+
*
302+
* Token skalasına geçerken ham CSS 71.492'den 78.377 byte'a çıktı ama aynı
303+
* derlemede gzip 13.366'dan 13.125'e, brotli 11.417'den 11.242'ye indi:
304+
* yüzlerce kez tekrarlanan var(--space-8), 70 ayrı keyfi değerden daha iyi
305+
* sıkışıyor. Cloudflare sıkıştırılmış servis ediyor, yani gerçek bütçe gzip.
306+
*
307+
* Ham eşik yine de duruyor ama artık asıl ölçü değil, emniyet sınırı: iyi
308+
* sıkışan ama kopyala-yapıştır büyümüş bir stil dosyasını yakalamak için.
309+
*/
299310
const css = Buffer.concat(cssFiles.map((file) => fs.readFileSync(file)));
300-
check(css.length < 72_000, `Derlenmiş CSS gereksiz büyüdü: ${css.length} byte.`);
301-
check(gzipSync(css).length < 16_000, `Gzip CSS bütçesi aşıldı: ${gzipSync(css).length} byte.`);
311+
const gzipped = gzipSync(css).length;
312+
check(gzipped < 14_000, `Gzip CSS bütçesi aşıldı: ${gzipped} byte.`);
313+
check(css.length < 88_000, `Ham CSS emniyet sınırını aştı: ${css.length} byte.`);
302314

303315
if (errors.length) {
304316
process.stderr.write(`${errors.map((error) => `- ${error}`).join('\n')}\n`);

0 commit comments

Comments
 (0)