问题描述
我刚刚在这里找到了Dean Edwards javascript packer:
I just found Dean Edwards javascript packer here:http://dean.edwards.name/packer/
它有几个选项,
- Base62编码
- 缩小变量
为了测试它,我采用了最新版本的jquery已经缩小到56kb并使用缩小变量在上面的页面上运行它,结果是相同大小的文件,56kb。
To test it I took the latest version of jquery that is already minified to 56kb and ran it on that page above with shrink variables, the result is the same size file, 56kb.
然后我再次运行原始文件,同时选择了Base62编码和收缩变量,结果是42kb文件。
I then ran the original file again with both Base62 encode and Shrink variables selected and the result was a 42kb file.
现在我不知道很多关于缩小和打包的事情然后它会使文件大小化。但我很好奇Base62编码在做什么,使用它是不是很糟糕?我看到它使文件小得多,但它会在以后创建更多的工作/负载以在页面上解码吗?
Now I don't know a lot about minifying and packing other then it makes the filesize smaller. But I am curious as to what Base62 encode is doing, is it bad to use it? I see it makes the file much smaller but does it create more work/load later on to decode it on the page?
推荐答案
Base 62只不过是。也就是说,它可用于通过非常短的版本来表示非常长的普通文本。
Base 62 is nothing but a positional notation. That is, it can be used to represent very long normal text by a very shorter version.
使用Base62在js可以被客户端使用之前添加额外的步骤。对于jQuery类库,此步骤可能需要额外100毫秒到500毫秒的时间在客户端上,具体取决于许多因素。
Using Base62 adds an extra step before the js can be put to use by clients. For jQuery kind of library this step may take an extra 100ms to 500ms of time on clients, depending on many factors.
现在我们可以比较下载时间的减少时间脚本执行脚本所需的额外时间。它可以减少50ms的下载时间,但需要额外的100ms来处理它。收益递减!!
Now we can compare the reduction in time to download the script to extra time taken to execute the script. It may reduce download time by 50ms but takes an extra 100ms to process it. Diminishing returns!!
这篇关于Base62编码一个javascript文件是不是很糟糕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!