only really scratches the surface of what the timeline can do.
Rather than just showing the amount of time the function takes, it also splits it into loading, scripting, rendering,
and painting. These are extremely useful for knowing why a function is taking longer than it should. The loading
category is where any XHR (AJAX) calls are made as well as parsing the HTML. The logic within the function is
included in the scripting category. Rendering is where the DOM manipulation takes place, primarily recalculating
styles and layout. Paint is where the browser updates what is being shown to match the outcome of the rendering,
including any changes on canvas and other elements that are not directly DOM related.
In Chapter 2, we use canvas for a simulation of birds flocking (known as Boids) and so I have recorded that using
the timeline to show you how it works. Figure 1-2 shows the events timeline, useful for timing functions and visually
seeing the stack that they produce. There are only two different colors shown in the screenshots. This is because there
are very few DOM elements due to using a canvas and so there is no loading and rendering required. The lack of DOM
is also the same reason for the patterns within the timeline, if we were recording performance of a regular website,
then we might see changes on scrolling or hovering over a button; so the timeline is definitely powerful for more than
canvas animations! Figure 1-3 shows the frames timeline. This measures the Frames Per Second (FPS) of the page
because a low FPS can make a site or animation look ”janky” instead of the smooth experience that people expect.
The third screenshot of this section, Figure 1-4, shows the memory timeline; you can see from the spikes that the
memory stores more and more until the garbage collector comes along and clears the memory that is storing old data.
You will notice that there is quite a lot of whitespace below the timeline. This space is for a graph showing the amount
of DOM nodes and event handlers (as you can see in Figure 1-5, which shows the timeline for a basic portfolio website
I once made).
B.原文的翻译JavaScript的创造力JavaScript控制台
每个浏览器都有不同的开发工具,有些是相似的,有些完全不同但有相似性,所有的浏览器已经是JavaScript控制台。这是其中记录所有的错误,但它往往比更强大只是一个错误日志。我将讨论它从谷歌浏览器的观点,但大多数的浏览器有非常相似的命令。论文网
访问变量
通常你会想知道一个变量的值,这样就可以验证它是你所期望的,甚至只是学习什么数据如何被构造(特别是对象)。要做到这一点,只需键入变量的名字进入的JavaScript
控制台和值将是名称下面的输出,这适用于所有类型,包括对象和数组。有一个一些方法通过控制台访问变量:
代码后r个•UN - 如果你只关心最后的结局,只是做我解释
上面并键入变量名。
•断点 - 我将详细不久,但在许多讨论调试器断点
其它语言,你可以添加一个断点,允许你检查在变量被执行在断点代码中的点。
•调试报告 - 您可以手动在你的代码写入调试器添加断点;在你的代码。它通常是更容易使用断点,但值得了解的调试器声明。
•里面的代码 - 您可以从代码中登录到控制台。它通常是更容易使用
断点,但如果你希望你可以写的console.log('富')登录;内的代码。
•作为表 - 这是目前仅在谷歌Chrome和Firebug的使用,但它是一个非常有用的方法来查看数组作为表格数据,其中每个指标一行。通过运行console.table(阵列);从任内的代码或控制台内(我想从控制台直建议,断点期间,因为它是不兼容其他浏览器)。
- 上一篇:ASP.NET技术英文文献和中文翻译
- 下一篇:MVC设计模式和Spring,Struts框架英文文献和中文翻译
-
-
-
-
-
-
-
java+mysql车辆管理系统的设计+源代码
河岸冲刷和泥沙淤积的监测国内外研究现状
当代大学生慈善意识研究+文献综述
杂拟谷盗体内共生菌沃尔...
大众媒体对公共政策制定的影响
十二层带中心支撑钢结构...
中考体育项目与体育教学合理结合的研究
酸性水汽提装置总汽提塔设计+CAD图纸
乳业同业并购式全产业链...
电站锅炉暖风器设计任务书