-
-
Notifications
You must be signed in to change notification settings - Fork 225
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
Do not escape characters in string literals when they are supported by the specified encoding #619
Comments
Good idea! Internally, there could be a cost function:
For ASCII, it would be
Babili could potentially run the script through all of the encodings to determine which is shortest. |
How do I disable this string-literal-mangling feature? It's bloating my data-heavy files by a significant amount. |
This file balloons up monstrously when run through babel-minify: https://github.com/TehShrike/majority-text-family-35-revelation/blob/master/revelation.json |
Any chances it will be added before |
This seems to be something babel-core is doing, rather than babel-minify. If using the Passing {"presets": ["minify", "env"], "minified": false} instead of {"presets": ["minify", "env"]} seems to be a workaround, although it results in more spaces in the output. |
It shouldn't matter what the output of I understand that you are only suggesting a workaround, I just wanted to clear up any possible misconception that this may not be a |
Actually minify makes code larger for utf-8 files, for now you can use this: |
Your workaround helps, however, |
…quences It can make the "minified" output more than twice bigger than the original input. See the issue babel/minify#619 for more information.
I was experimenting with
babili
and found that the minified code it produces is significantly larger thanclosure
(100 KiB vs 120 KiB). As it turns out, the problem is caused by the waybabili
handles (unicode) string literals.Suppose that the code contains the string
"теѕт"
(all Cyrillic characters). Thenbabili
converts it to"\u0442\u0435\u0455\u0442"
. OTOH,closure
with the--charset utf8
option leaves the string in the original form. In fact, with that flag,closure
converts"\u0442\u0435\u0455\u0442"
to"теѕт"
.So I propose to introduce to
babili
an option similar toclosure
's--charset
. Of course, this should use a conservative setting by default (eg ascii), because otherwise the minified script would then require to be loaded withcharset="..."
in the<script>
tag.The text was updated successfully, but these errors were encountered: