自定义函数(p,a,c,k,e,d)用于什么? [英] What does the custom function(p,a,c,k,e,d) used for?

查看:95
本文介绍了自定义函数(p,a,c,k,e,d)用于什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在他们的javascript代码中看到很多网站都有一些功能(p,a,c,k,e,d)。不同的网站可能有不同的功能,但为什么他们都使用这个参数名称(p,a,c,k,e,d)?我的意思是它是一个标准或什么或库,他们遵循相同的约定。

I have seen a lot of websites having some function (p,a,c,k,e,d) in their javascript code. The different websites may have different body of this function but why they all use this parameter names (p,a,c,k,e,d) ? I mean is it a standard or something or a library, that they follow same convention.

其次,似乎这个函数应该在页面执行后立即执行loads.Like来自网站的以下片段。

Secondly,it seems that this function is supposed to be executed as soon as the page loads.Like the following snippet from a website.

你能帮助我理解这段代码: eval()用于计算像 2 + 3 这样的表达式但是下面的代码如何将函数传递给它?

Can you help me in understanding this code: eval() is used to evaluate expressions like 2+3 but how the following code is passing a function to it?

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

这个问题可能听起来很愚蠢但是我非常想了解函数(p,a,c,k,e,d)之谜,所以不要downvote。

This question may sound stupid but seriously I want to understand the mystery of function(p,a,c,k,e,d),so don't downvote.

推荐答案

因此,如果您使用 http:// matthewfl。 com / unPacker.html 正如我在评论中发布的那样,我t解包代码:

So if you use http://matthewfl.com/unPacker.html as I posted in the comments, it "unpacks" the code into this:

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

它似乎不是恶意的。有关您为什么要使用此功能的软性论据,请参阅 javascript packer与minifier

It doesn't seem to be malicious. For a soft argument on why you would use this, see javascript packer versus minifier:


Packed较小但速度较慢。

Packed is smaller but is slower.

甚至更难调试。

大多数众所周知的框架和插件都只是缩小了。



Packer做的更多只是重命名变量和参数,它实际上使用Base62映射
源代码,然后必须通过eval在客户端
一侧重建(为了可以使用。

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.

在这里踩eval()是邪恶问题,这也会在客户端产生
大量的开销页面加载当你启动
包装更大的JS库,比如jQuery。这就是为什么只建议在你的生产JS上缩小
,因为如果你有足够的代码来
需要打包或缩小,你有足够的代码使eval()
阻塞客户端在页面加载期间。



Minifier只删除不必要的东西,比如空白字符
,其中Packer更进一步,并尽其所能为
最小化javascript的大小。例如,它将变量重命名为
较小的名称。

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.

这篇关于自定义函数(p,a,c,k,e,d)用于什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆