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

Rollup example styles using 'property-specificity' style resolution #675

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

Conversation

necolas
Copy link
Contributor

@necolas necolas commented Aug 22, 2024

What changed / motivation ?

Demonstrate impact on JS bundle size of styleResolution being 'property-specificity' rather than the default of 'application-order'.

Additional Context

'application-order' generates hundreds of null values in the compiled JS output.

'property-specificity' doesn't do this and lends itself to more compact CSS bundles too.

Copy link

github-actions bot commented Aug 22, 2024

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.qyYyphKelX /tmp/tmp.yC4ezMpNAX

Results Base Patch Ratio
stylex/lib/stylex.js
· compressed 899 899 1.00
· minified 3,223 3,223 1.00
stylex/lib/StyleXSheet.js
· compressed 1,258 1,258 1.00
· minified 3,748 3,748 1.00
rollup-example/.build/bundle.js
· compressed 563,563 504,676 0.90 !!
· minified 10,185,348 5,725,352 0.56 !!
rollup-example/.build/stylex.css
· compressed 100,211 100,185 1.00 -
· minified 759,868 760,063 1.00 +

@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 Aug 23, 2024
@nmn
Copy link
Contributor

nmn commented Sep 4, 2024

compressed | 563,563 | 504,676 | 0.90

So it looks like it saves 10% of the JS bytes in this case, if I'm reading the table right?

Should we add a new example so we can maintain a comparison going forward? There are some further optimisations that can be made to the 'application-order' case as well.

@necolas
Copy link
Contributor Author

necolas commented Sep 9, 2024

I think we should be working to get rid of the options and standardize on property-specificity

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.

3 participants