使用Terser缩小对数学,号码等的电话

发布于 2025-02-03 13:24:33 字数 467 浏览 1 评论 0原文

Terser为我的项目制作的代码包含许多对JavaScript MATH对象的调用,我想知道是否有一种简单的方法来缩小这些调用。

这是带有MATH突出显示的刻度代码的一部分的屏幕截图(总共有几千个调用MATH):

sstatic.net/qi4y0.png“ rel =“ nofollow noreferrer 通过设置const min = math.min等,在我的原始代码中进行优化,但这很难维护,通常是可憎的微型优化。

正如我所看到的,在Mangle选项中无法使用属性,因为属性明确无助于内置的JavaScript属性。

是否有人知道如何使用Terser缩小Math,数字等的调用?

The code that Terser produces for my project contains many calls to the Javascript Math object and I am wondering if there is an easy way to minify these calls.

Here is a screenshot of part of the minfied code with Math highlighted (altogether there are almost a thousand calls to Math):

enter image description here

I could certainly do the optimization in my original code by setting const min = Math.min etc, but this would be hard to maintain and generally an abominal micro optimization.

As I see it properties in the mangle options cannot be used for this, as properties explicitly will NOT work for built-in Javascript properties.

Does anybody have an idea how calls to Math, Number, etc. can be minified with Terser?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寂寞陪衬 2025-02-10 13:24:33

我找不到使用Terser的解决方案。

但是我得出的结论是,由于以下原因,将所有调用到MATH的呼叫是没有多大意义的:

  • 混淆并不能真正改善。该映射将在文件中可见,因此,任何决心解开代码的人都将很容易取消启动。
  • 文件大小可能较小,但是由于文件通过Internet发送了GZZ,因此实际差异将很小或无,因为多个字符串出现(例如“数学”呼叫''将通过GZPIPPIPT压缩。

因此总而言之,这似乎既不可能也不必需。

I could not find a solution for this using Terser.

BUT I came to the conclusion, that it would not make much sense to minify all calls to Math for the following reasons:

  • Obfuscation does not really improve. The mapping would be visible inside the file, so unmapping would be very easy for anyone determined to unobfuscate the code.
  • File size may be smaller, but since files are sent gzipped over the internet, the actual difference would be very small or none, since multiple string occurences like calls to 'Math' will be compressed by gzipping.

So in conclusion this seems to be neither possible nor necessary.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文