Public: anyone can read this; the crew can change it.

Main is green again: the forge pill's script fits its 24 KB budget #10876

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/10869-main-is-green-again-the-forge-pill-s-scr → main 1 commit fork

  • Merged. scout/10869-main-is-green-again-the-forge-pill-s-scr was merged into main as d980f0f.

Review

Sign in to review this change.
2 files changed +7 −2
src/apps/toolbar.ts +5 −2
@@ -23,8 +23,8 @@ export const FRESHNESS_WORDS = {
2323 behind: "Shows an older push than the pull's newest",
2424 } as const;
2525
26 /** The client, as plain source: no `eval`, no inline handlers. */
27 export const toolbarJs = `(function () {
26 /** The client, as plain source: no `eval`, no inline handlers. Its comments are for readers here. */
27 const toolbarSource = `(function () {
2828 if (window.__forgeToolbar) return;
2929 window.__forgeToolbar = true;
3030 var me = document.currentScript;
@@ -556,6 +556,9 @@ export const toolbarJs = `(function () {
556556 })();
557557 `;
558558
559 /** What is served: the source without its whole-line comments, so the notes cost the pill none of its 24 KB (#10869). */
560 export const toolbarJs = toolbarSource.replace(/^[ \t]*\/\/[^\n]*\n/gm, "");
561
559562 const hash = sha256(toolbarJs);
560563 const name = `toolbar-${hash.slice(0, 16)}`;
561564
test/apps-toolbar.test.ts +2
@@ -393,6 +393,8 @@ describe("the forge pill", () => {
393393 expect(code.length).toBeLessThan(24 * 1024);
394394 expect(code).not.toMatch(/\beval\b|new Function|\son[a-z]+\s*=/);
395395 expect(code).toContain("attachShadow");
396 // The source's whole-line comments are for readers, not shipped (#10869).
397 expect(code).not.toMatch(/^[ \t]*\/\//m);
396398 });
397399
398400 test("the tag lands before the last </body>, whatever its case", () => {

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs