JavaScript的即时编译 [英] JavaScript Just In Time compilation

查看:395
本文介绍了JavaScript的即时编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对HTML页面相当大的JavaScript的设备。

I have a quite big JavaScript for HTML page for a device.

但它是一个有点慢。我试图COM pressing JavaScript文件,但它仍然不能令人满意。

But it's a bit slow. I tried compressing JavaScript files but it's still not satisfactory.

所以我在想,是有可能使它作为一个及时,即编译转换为机器code和使用它? (希望我的理解是正确的),我使用基于WebKit浏览器。

So I was thinking, is it possible to make it as a "Just in Time" that is compiled converted to machine code and use it? (Hope my understanding is correct) I use a WebKit based browser.

有人请谁做了这一点,请提供链接到如何页面或大致相同的信息。

Anybody please who have done this, please provide links to "How To" pages or info about the same.

推荐答案

的Javascript Safari和Chrome浏览器执行JIT编译了。事实上,在wides $ P $垫使用不唯一的浏览器IE8是和更早版本。这是主要的原因,IE8是如此比竞争对手慢得多,这些天之一。

Both Safari and Chrome do JIT compilation of Javascript already. In fact, the only browser in widespread use that doesn't is IE8 and earlier. This is one of the main reasons why IE8 is so much slower than the competition these days.

但你的问题的字里行间,我的猜测是,你不太理解汇编是JIT。 JIT编译发生在浏览器上;你不需要以任何方式更改您的code在所有为了使浏览器能够做到JIT编译就可以了你。

But reading between the lines of your question, my guess is that you're not quite understanding what JIT compilation is. JIT compilation happens on the browser; you don't need to change your code in any way at all in order for the browser to be able to do JIT compilation on it for you.

这听起来像什么,你实际上想的是字节code编写,如Java一样。该字节code实际上是一个中途编译语言,然后本身JIT编译当你运行该程序。如果这是你在想什么,我可以证实,这不是基于浏览器的Javascript code选项。

What it sounds like you're actually thinking of is bytecode compilation, such as Java does. This bytecode is effectively a half-way compiled language which is then itself JIT compiled when you run the program. If this is what you're thinking of, I can confirm that this is not an option for browser-based Javascript code.

谷歌一直在玩弄一个名为本地客户端(氯化钠)技术,该技术将允许您提供编译code到浏览器,但这还不可用,除了在Chrome的开发版本。

Google have been toying with a technology called 'Native Client' (NaCl), which would allow you to provide compiled code to the browser, but this is not available yet except in development versions of Chrome.

在任何情况下,编译可能会让你的code运行更快,但它不会解决为什么它运行缓慢的根本问题,这很可能是为解决一个更好的事情。 (编译甚至code会表现很差,如果有瓶颈;编制本身并不神奇地让慢code更好)

In any case, compiling may make your code run quicker, but it wouldn't solve the fundamental issue of why it's running slowly, which is likely to be a far better thing to resolve. (even compiled code will perform badly if it has bottlenecks; compilation in itself doesn't magically make slow code better)

如果你想找出为什么你的脚本运行缓慢,我建议使用分析工具,如一个内置的Firebug或Chrome的开发者工具。这将帮助你识别哪些运行缓慢您的code的部分。

If you want to find out why your script is running slowly, I recommend using a profiling tool, such as the one built into Firebug or Chrome's Developer Tools. This will help you identify the parts of your code which are running slowly.

您也可以尝试在 YSlow的工具,也可以给JavaScript性能的有用信息。

You could also try the YSlow tool, which can also give useful information on javascript performance.

您还规定,你已经融为一体pressed你的脚本,试图让它走得更快。 COM pressing脚本将它帮助的下载的更快(因为它是一个较小的文件),但它不会做了code。在运行的速度。

You also state that you've compressed your script to try to get it to go faster. Compressing the script will help it to download quicker (because it's a smaller file), but it won't do anything for the speed that the code runs at.

我希望帮助。

这篇关于JavaScript的即时编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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