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

Unicode minification #773

Closed
privatenumber opened this issue Feb 9, 2021 · 4 comments
Closed

Unicode minification #773

privatenumber opened this issue Feb 9, 2021 · 4 comments

Comments

@privatenumber
Copy link
Contributor

I noticed one of my asset files was minifying 25% worse with esbuild compared to Terser. I looked into it and it looks like it's because of how esbuild handles unicode. For example, Terser preserves "丂", but esbuild seems to convert it to "\u4E02".

I'm wondering if it's possible to preserve these characters as is.

For reference, I linked the Terser and esbuild minified versions of the asset here.

@lukeed
Copy link
Contributor

lukeed commented Feb 9, 2021

You can use charset for this

@evanw
Copy link
Owner

evanw commented Feb 9, 2021

Yes, this is easy to change: https://esbuild.github.io/api/#charset. It's not done by default both because Unicode can sometimes cause code to break if you haven't configured your server to send the appropriate Content-Type headers, and because Unicode also makes your JavaScript slower to parse.

@evanw evanw closed this as completed Feb 9, 2021
@privatenumber
Copy link
Contributor Author

Thank you both!!

@lukeed
Copy link
Contributor

lukeed commented Feb 9, 2021

That's a super interesting V8 post, thanks for sharing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants