Javascript 浏览器如何执行javascript

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5317190/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 16:37:45  来源:igfitidea点击:

How do browsers execute javascript

javascript

提问by

I'm trying to figure out if web browsers use an interpreter to execute javascript, or some sort of compiler. It is well known that scripting languages are interpreted not compiled; however there is the JScriptCompilerthat can compile javascript into MSIL. This leaves me to wonder if IE, FF, Chrome etc are using some sort of compiler or if it's an interpreter.

我试图弄清楚网络浏览器是否使用解释器来执行 javascript 或某种编译器。众所周知,脚本语言是解释而不是编译;但是有JScriptCompiler可以将 javascript 编译成 MSIL。这让我想知道 IE、FF、Chrome 等是否正在使用某种编译器,或者它是否是一个解释器。

Can anyone cite the specific method in which browsers run javascript?

任何人都可以引用浏览器运行javascript的具体方法吗?

采纳答案by Pascal MARTIN

In the past, Javascript was interpreted -- and nothing more.

过去,Javascript 是被解释的——仅此而已。

In the past two years or so, browsers have been implementing new Javascript engines, trying to compile some portions of code, to speed Javascript up.

在过去两年左右的时间里,浏览器一直在实现新的 Javascript 引擎,试图编译部分代码,以加速 Javascript。


For more informations on what has been done for Mozilla Firefox, you should take a look at :


有关为 Mozilla Firefox 所做的工作的更多信息,您应该查看:

For more informations about Chrome's engine, you'll want to read :

有关 Chrome 引擎的更多信息,您需要阅读:

And for webkit (safari):

对于 webkit (safari)

Not sure what has been (or is being)done on other browsers -- but I suppose the same kind of thing exists, or will exist.

不确定在其他浏览器上已经(或正在)做什么——但我想同样的事情存在,或者将存在。


And, of course, for more informations : JavaScript engine, on wikipedia.


当然,更多信息:JavaScript 引擎,维基百科。

回答by Mohsin Ahmed

JScript is a scripting language provided by microsoft. Its compilation is taken care by CLR. Also it can be interpreted. It have tighter integration with Visual studio.

JScript 是微软提供的一种脚本语言。它的编译由 CLR 负责。也可以解释。它与 Visual Studio 有更紧密的集成。

Have a look at http://msdn.microsoft.com/en-us/library/72bd815a%28v=vs.80%29.aspxfor detail Jscript description.

查看http://msdn.microsoft.com/en-us/library/72bd815a%28v=vs.80%29.aspx了解详细的 Jscript 描述。

回答by Frizi

javascript scripts are usually interpreted in web browsers (not sure about chrome and V8), but here and there you can find some standalone software which can compile it more or less correctly. This language isn't as fast as many other and his speed and functionality depends on browsers engine.

javascript 脚本通常在网络浏览器中解释(不确定 chrome 和 V8),但在这里和那里你可以找到一些独立的软件,可以或多或少地正确编译它。这种语言不如其他语言快,他的速度和功能取决于浏览器引擎。