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

Shorten property names in compiled JS output #741

Open
nmn opened this issue Oct 10, 2024 · 0 comments
Open

Shorten property names in compiled JS output #741

nmn opened this issue Oct 10, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@nmn
Copy link
Contributor

nmn commented Oct 10, 2024

StyleX generates objects mapping propertyNames to classNames after compilation:

const styles = {
  base: {
    margin: 'khsdgdkj',
    color: 'ksjhgdjf',
    "@media (min-width: 768px)_color": "skjhgfjh", // Legacy deprecated pattern
    "::before_color": "djshgf", // Usage of pseudo elements
    // ...
  }
};

Add a simple transformation step that shorten all property names to a short, but still unique string. This would reduce the size of the JS without any actual changes at runtime:

const styles = {
  base: {
    m: 'khsdgdkj',
    c: 'ksjhgdjf',
    _hash: "skjhgfjh",
    // ...
  }
};
@nmn nmn added the enhancement New feature or request label Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant