gpt4 book ai didi

javascript - 自定义函数(p,a,c,k,e,d)有什么用?

转载 作者:行者123 更新时间:2023-12-03 00:26:04 25 4
gpt4 key购买 nike

我见过很多网站的 JavaScript 代码中都包含一些函数 (p,a,c,k,e,d)。不同的网站可能有不同的函数体,但它们都使用相同的参数名称(p,a,c,k,e,d)。它是标准还是库还是其他东西?

其次,这个函数似乎应该在页面加载后立即执行。就像下面来自网站的片段一样。

你能帮我理解这段代码吗? eval() 用于计算诸如 2+3 之类的表达式,但是以下代码如何将函数传递给它?

try{
eval(
function(p,a,c,k,e,d)
{
//some code goes here
}
}catch(err){}

最佳答案

所以如果你使用http://matthewfl.com/unPacker.html正如我在评论中发布的,它将代码“解压”为:

(function()
{
var b="some sample packed code";
function something(a)
{
alert(a)
}
something(b)
}
)();

看起来并没有恶意。有关为什么要使用它的软论证,请参阅 javascript packer versus minifier :

Packed is smaller but is slower.

And even harder to debug.

Most of the well known frameworks and plugins are only minified.


Packer does more then just rename vars and arguments, it actually maps the source code using Base62 which then must be rebuilt on the client side via eval() in order to be usable.

Side stepping the eval() is evil issues here, this can also create a large amount of overhead on the client during page load when you start packing larger JS libraries, like jQuery. This why only doing minify on your production JS is recommend, since if you have enough code to need to do packing or minify, you have enough code to make eval() choke the client during page load.


Minifier only removes unnecessary things like white space characters where as a Packer goes one step further and does whatever it can do to minimize the size of javascript. For example it renames variables to smaller names.

关于javascript - 自定义函数(p,a,c,k,e,d)有什么用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21423397/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com