Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minify compiled style keys #875

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Minify compiled style keys #875

wants to merge 7 commits into from

Conversation

necolas
Copy link
Contributor

@necolas necolas commented Jan 29, 2025

What changed / motivation ?

The keys of compiled styles are hashed / minified.

This is done to try to reduce the size of the StyleX-generated JavaScript

Fix #741

Pre-flight checklist

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 29, 2025
Copy link

github-actions bot commented Jan 29, 2025

workflow: benchmarks/size

Comparison of minified (terser) and compressed (brotli) size results, measured in bytes. Smaller is better.

@stylexjs/[email protected] size:compare
./size-compare.js /tmp/tmp.n48nDFbOOb /tmp/tmp.Sw0Peyt75m

Results Base Patch Ratio
stylex/lib/stylex.js
· compressed 1,013 729 0.72 !!
· minified 3,305 2,541 0.77 !!
stylex/lib/StyleXSheet.js
· compressed 1,266 1,266 1.00
· minified 3,776 3,776 1.00
rollup-example/.build/bundle.js
· compressed 567,110 537,515 0.95 !!
· minified 10,232,512 7,435,945 0.73 !!
rollup-example/.build/stylex.css
· compressed 100,628 100,628 1.00
· minified 755,718 755,718 1.00

":hover_backgroundPositionY": null,
":hover_backgroundRepeat": null,
":hover_backgroundSize": null,
kKVMdj: "xeuoslp",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't 4/5 characters be enough for this use-case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is 5 chars, plus a prefix. (Converting the first character only if it's a number is not really safe.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we drop the prefix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shorten property names in compiled JS output
4 participants