html 页面中哪些元素将首先加载?

发布于 2024-11-09 08:00:12 字数 68 浏览 6 评论 0原文

我想知道打开网页时哪些元素(html 标签、脚本、样式、图像)将首先加载?

有人可以帮助我吗? 提前致谢。

I want to know which elements (html tags, scripts, styles, images) will load first when opening a web page?

Can anybody help me?
Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

世界如花海般美丽 2024-11-16 08:00:13

HTML 页面是动态解释的,并从上到下完整地读取 - 因此,第一个元素将首先加载,最后一个元素将最后加载。

例如,如果您将脚本放置在 body 的顶部,那么它将在加载正文中的任何元素之前执行;而如果将 is 放在 body 的末尾,则正文中的所有元素都将加载,然后脚本将执行。

不过,脚本和图像等外部源的加载顺序可能因浏览器而异(虽然大多数情况下遵循相同的约定) - 其想法是打开连接以请求这些资源,然后请求大小等内容、速度和延迟受到质疑——而这些通常仍然是顺序的和阻塞的。

HTML pages are interpreted on the fly and read in their entirety from top to bottom - so, the first elements will load first, the last last.

For instance, if you place a script at the top of the body then it will be executed prior to any elements within the body loading; whereas if you place is at the end of the body, all elements within the body will load then the script will execute.

The order of loading for external sources such as scripts and images, though, might differ from browser to browser (while for the most part following the same conventions) - the idea is that connections will be open to request these resources and then things like size, speed and latency come into question - and these are most often still sequential and blocking.

唔猫 2024-11-16 08:00:13

显然,html 将首先加载,因为这会指示浏览器扩展要求:
图像、脚本、外部样式表等

之后,加载顺序非常随机 - 大多数浏览器将启动多个连接,并且无法预测它们返回的顺序。

The html will load first obviously as this instructs the browser on the extended requirements:
images, scripts, external stylesheets etc

After that, the load order is pretty random - multiple connections will be initiated by most browsers and the order in which they return cannot be predicted.

黯然 2024-11-16 08:00:13

从上到下开始执行...

Execution start from Top to bottom ...

无力看清 2024-11-16 08:00:13

Html 和它的狗屎从上到下,脚本和 CSS 更少从下到上阅读。代码以这种方式编写,因为每个都是列表的一部分,并且在一条路径上按降序设置;沿着另一条路上升。如果你的文件以不同的方式堆叠,那么旅程可能会发生变化,因此会出现“狗屎去哪儿”的争论......所以 Html div 下降到一个 Head;然后身体让我们做好准备。使用 script 标签在 html 本身区域中设置 javascript 脚本标签。这可能看起来有点多,但在该区域中为脚本创建 id 标记将在调用该部分时设置脚本。 css 之类的东西也是如此。所以我是这样想的,如果有人感兴趣的话,我通常会在 johnaldrin.net 上的一些简洁的视差页面上获得快速加载。我总是没有绘画和示例脚本可以玩,自定义 ASP Web 表单...数字艺术与有趣的元标签混合,驱动我用 .NET C# 开发的 SEO 引擎!

Html and its shit go top bottom, scripts and css less read bottom to top. The code is written this way because each is part of a list and it is being set in descending order on one path; Ascending on the other path. The Journey can shift if your files are stacked differently, thus the argument of 'where shit goes'... So the Html divs down to a Head; And then the body sets us up. Set your javascript script tags in the area of the html itself using the script tags. This might seem a bit much but creating an id tag to a script in that area will set the script when that section is called for instance. Same goes with css and stuff. SO I think like that and typically get fast loads on some neat parallax pages I have on johnaldrin.net if anyone is interested. I always have no paintings and sample scripts to play with, custom ASP web forms... Digital ARt mixed with fun Meta tags, driving an SEO Engine I developed in .NET C#!

ら栖息 2024-11-16 08:00:12

没有标准的方法;浏览器可以自由地以任何他们喜欢的方式实现这一点。

如果您想了解浏览器是如何做到这一点的,请使用 Firebug、Chrome 开发者工具或 Safari Inspector 等工具。它们可以显示网络流量以及下载元素的顺序。

通常,下载顺序与 HTML 文档中的下载顺序相同,但浏览器可以打开多个到服务器的连接。在这种情况下,它可能会按文档顺序发送 2 或 5 个请求,但服务器可以按任意顺序响应。此外,某些部分可能会从缓存加载。

There is no standard way; browsers are free to implement this in any way they like.

If you want to know how your browser does it, use a tool like Firebug, Chrome's Developer Tools or Safari Inspector. They can show the network traffic and in which order elements are downloaded.

Usually, the download order is the same as in the HTML document but browsers can open more than a single connection to a server. In that case, it might send 2 or 5 requests in document order but the server can respond in arbitrary order. Also some parts might be loaded from cache.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文