diff --git a/.changeset/render-class-aliases.md b/.changeset/render-class-aliases.md new file mode 100644 index 0000000000000..a2b62ddb96a27 --- /dev/null +++ b/.changeset/render-class-aliases.md @@ -0,0 +1,7 @@ +--- +'@astryxdesign/cli': patch +--- + +[experimental] `astryx experimental export`: a large exported page that repeats an element names each repeated list of the StyleX classes Astryx's packages write (the `x…` classes) by one short class in its first paint, when those repeated lists add up to at least 16 KB; the page's own StyleX classes keep their names, so a large table or list writes a much smaller file: a 10,000-row grid goes from 52 MB to 18 MB. The page looks the same, also where scripts are blocked; its script draws with StyleX's own classes, and `--reverse` gives the page back exactly. The experimental `render()` takes `keepClassNames: true` for a caller that styles the file's markup with its own copy of the StyleX styles. + +@josephfarina diff --git a/.changeset/render-image-once-markup.md b/.changeset/render-image-once-markup.md new file mode 100644 index 0000000000000..d5b86efe08908 --- /dev/null +++ b/.changeset/render-image-once-markup.md @@ -0,0 +1,7 @@ +--- +'@astryxdesign/cli': patch +--- + +[experimental] `astryx experimental export`: an exported page's script reads from the first paint an image the first paint shows through `src`, `srcset` or `poster` when the page's code names it as a whole string by that exact path or https address. The file holds each such image one time fewer: a page with one 450 KB local photo goes from about 2.05 MB to 1.45 MB, and an https image the page shows through `src`, `srcset` or `poster` is held once (the same photo by an https address: about 1.46 MB to 0.86 MB). The first paint is the same, also where scripts are blocked. + +@josephfarina diff --git a/.changeset/render-module-script.md b/.changeset/render-module-script.md new file mode 100644 index 0000000000000..fbb9d854f1ed0 --- /dev/null +++ b/.changeset/render-module-script.md @@ -0,0 +1,7 @@ +--- +'@astryxdesign/cli': patch +--- + +[experimental] `astryx experimental export`: an exported page's script is a module script when it runs the same in strict mode, so it runs once the file is parsed: a browser paints the page before the script draws it, and on the pages measured a small page shows its first paint about 200 ms sooner on a slow phone, with about the same time until it responds. A page whose script bundles a file that is not an ES module and does not ask for strict mode (CommonJS code, or a side-effect file with no `import` or `export`), or code that reads `document.currentScript`, keeps a classic script. + +@josephfarina diff --git a/.github/scripts/render-interaction-parity.browser.test.mjs b/.github/scripts/render-interaction-parity.browser.test.mjs index 4eb76b750ff39..78793fd71d964 100644 --- a/.github/scripts/render-interaction-parity.browser.test.mjs +++ b/.github/scripts/render-interaction-parity.browser.test.mjs @@ -178,6 +178,7 @@ const ROUTES_LAZY = `document.addEventListener('click', e => { e.preventDefault(); window.dispatchEvent(new Event('lazy')); }, true); +export {}; `; // A page that registers its own click and key handlers the ways pages do: one diff --git a/apps/docsite/scripts/generate-landing-template-previews.mjs b/apps/docsite/scripts/generate-landing-template-previews.mjs index 0c289ea010e5f..7fc237a4bca3d 100644 --- a/apps/docsite/scripts/generate-landing-template-previews.mjs +++ b/apps/docsite/scripts/generate-landing-template-previews.mjs @@ -75,6 +75,13 @@ const templatesDir = path.resolve( // high-density screen. It must be a width the image optimizer allows. export const PREVIEW_IMAGE_WIDTH = 640; +/** + * How a preview whose markup the site takes is rendered: the site's own + * StyleX styles style it, so it keeps StyleX's class names instead of the + * short aliases whose rules only the file's own stylesheet holds. + */ +export const PREVIEW_MARKUP_RENDER = {keepClassNames: true}; + // The page fills the frame and never scrolls, as a live template preview // fills its tile: without this, a template taller than the frame shows a // scrollbar where scrollbars are always visible. The card cannot run script @@ -97,7 +104,7 @@ const SOURCE_BLOCK = * The page's script, which the render puts after the embedded source. It * holds no closing script tag of its own: the render escapes that. */ -const PAGE_SCRIPT = /