简体   繁体   English

节点对象树如何进入浏览器

[英]How does the node object tree get in the browser

I understand that javascript is synchronous. 我了解javascript是同步的。

But how does the Node object tree get constructed is it done in the browser where the browser produces an object referred to as Node and all its properties for both the CSS engine to paint, and the javascript engine to transverse the html dom. 但是,如何在浏览器中完成Node对象树的构造,浏览器在浏览器中生成一个称为Node的对象,其所有属性供CSS引擎绘制和javascript引擎遍历html dom。 Or The page when downloaded, is loaded into javascript engine and javascript parses it to get the Node tree ready in the global execution context? 或下载后的页面已加载到javascript引擎中,并且javascript对其进行了解析,以便在全局执行上下文中准备好节点树? Eg 例如

Function(fetched_page) -> Node tree constructor 

Generally the browser will use native code to parse the HTML page contents as it is loading. 通常,浏览器将在加载时使用本机代码来解析HTML页面内容。

Any scripts contained in the page is executed as its found (unless loaded with a <script> tag with defer and/or async attributes). 页面中包含的所有脚本都将按照其找到的内容执行(除非加载了带有defer和/或async属性的<script>标记)。 This is why you can't refer to an element defined in the <body> of a page from within a script found in the <head> unless you wait for an "onload" event or similar - those elements don't exist yet. 这就是为什么除非等待"onload"事件或类似事件,否则不能从<head>找到的脚本中引用页面的<body>中定义的元素的原因-这些元素尚不存在。

The DOM-related functions that are available within the browser's JavaScript interpreter are normally just hooks to the same native code functions used within the browser itself. 在浏览器的JavaScript解释器中可用的与DOM相关的功能通常只是挂钩到浏览器本身使用的本机代码功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM