javascript 使用 Firebug Net Panel 计时:加载时间是多少?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4263789/
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-10-25 10:49:22  来源:igfitidea点击:

Timing with the Firebug Net Panel: What is the onload time?

javascriptfirebugtiming

提问by Martin Algesten

I'm using the Firebug net panel to see response times. On the net panel's status bar, the summary is displayed as follows:

我正在使用 Firebug 网络面板查看响应时间。在网络面板的状态栏上,摘要显示如下:

10 requests        90KB            10.22s (onload 6.57s)

10 个请求 90KB 10.22s (onload 6.57s)

What does that onload time mean? Does it mean that once the content was received from the server, it took another 6.57 seconds for the page to become usable (i.e. for the onready event to finish)?

加载时间是什么意思?这是否意味着一旦从服务器接收到内容,页面又需要 6.57 秒才能可用(即完成 onready 事件)?

Note: The site I'm testing is VERY heavy with Qooxdoo components and oodles of JavaScript.

注意:我正在测试的站点包含大量 Qooxdoo 组件和大量 JavaScript。

回答by Martin Algesten

You page initialization order is:

你的页面初始化顺序是:

  1. head scripts
  2. body scripts
  3. onload
  4. later things
  1. 头脚本
  2. 正文脚本
  3. 负载
  4. 后来的事情

So 'onload' is the time until the onload event is thrown and finished executing. The timing in Firebug for onload is all init up and including the onload event itself.

所以 'onload' 是直到 onload 事件被抛出并完成执行的时间。Firebug 中的 onload 时间都是初始化的,包括 onload 事件本身。

Onload waits for all resources referenced by the page up until onload has loaded (images, scripts, CSS, etc.). The things after onload are more initialisation - often triggered by setTimeout()to do stuff after everything is in place. Anything in setTimeout()is a new call stack, and not part of onload.

Onload 等待页面引用的所有资源,直到 onload 加载(图像、脚本、CSS 等)。onload 之后的事情更多的是初始化 - 通常setTimeout()在一切就绪后由做事情触发。其中的任何内容setTimeout()都是一个新的调用堆栈,而不是 onload 的一部分。

回答by Ionut Popa

  • 6.57 secs until the onload event is fired
  • 10.22 secs until all other things are loaded (eg set on the onload event)
  • 6.57 秒,直到 onload 事件被触发
  • 10.22 秒直到加载所有其他内容(例如在 onload 事件上设置)