javascript - 是否仍然值得在移动 JavaScript 上使用 eval 来提高性能?

标签 javascript performance mobile

To combine all modules into a single resource, we wrote each module into a separate script tag and hid the code inside a comment block (/* */). When the resource first loads, none of the code is parsed since it is commented out. To load a module, find the DOM element for the corresponding script tag, strip out the comment block, and eval() the code....

On an iPhone 2.2 device, 200k of JavaScript held within a block comment adds 240ms during page load, whereas 200k of JavaScript that is parsed during page load added 2600 ms. That's more than a 10x reduction in startup latency by eliminating 200k of unneeded JavaScript during page load!

http://googlecode.blogspot.co.uk/2009/09/gmail-for-mobile-html5-series-reducing.html https://developers.google.com/speed/docs/best-practices/mobile

gmail 文章已有三年多的历史,从那时起,移动性能有了很大的优势,例如 iOS 的 Nitro 和 JIT 进入移动设备。使用 eval 是否仍然可以提高性能?

最佳答案

自从 JavaScript 引擎变得如此高效以来,它不再是以前的技术问题。相反,在更像应用程序方面还有其他考虑因素。

enter image description here

现在有一些技巧在方法上有所不同,例如使用 web worker 进行 ajax 请求以释放线程,利用具有 CSS 转换和 requestAnimationFrame 甚至 asm.js 的 GPU。使用 localStorage/sessionStorage 和 Application Cache 是沿着这些路线的另一种方法,您可以真正预先获得大量客户端缓存,以避免调用除内容 JSON/图像数据 url/视频之外的任何内容,并将内容加载/执行到内存中需要从这些缓存中获取。

换句话说,现在是不同的时间,你的问题很有趣,但没有集中在正确的领域,无法真正改变网络应用程序的性能。

关于javascript - 是否仍然值得在移动 JavaScript 上使用 eval 来提高性能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19658226/

相关文章:

javascript - 将导入的函数分配为类方法?

python - 将记录收集到 Eve/mongodb 中的单个数组中以减少带宽

performance - 为什么有很多用户生成的表不是一个好主意

mobile - 用于注册的短信 (SMS) 验证

html - 使用 bootstrap 在移动设备上查看网站时,我的网站需要 flash 更改为静态图像吗?

javascript - PHP:两个 <select>,第一个已准备好填充,第二个我想填充值

javascript - 需要选中 jQuery Validate 复选框吗?

Django性能/内存使用率

javascript拖放,添加事件监听器。 -完全迷失了

javascript - 使用 JQuery 验证程序扩展时禁用错误消息