[英]do content added to DOM count for the total page load time?
I mean if I append some contents like this: 我的意思是如果我附加一些这样的内容:
<body>
//contents
<script>body.appendChild('<img src="new.png">');
// other contents
</body>
the browser will fire window.onload considering only the original html or it will take in consideration the load of the new image too? 浏览器会只考虑原始的html来激活window.onload,还是会考虑到新图像的负载? ( new.png
) ? ( new.png
)?
Besides that code/markup being incorrect, it will consider the new image. 除了代码/标记不正确之外,它还会考虑新的图像。 To append it to the DOM will be to download whatever the src
attribute points to. 将它附加到DOM将是下载src
属性指向的任何内容。
However, if this code was placed inside of a window.onload = function() { ... }
, then it wouldn't be considered because its download would not occur until your window was loaded. 但是,如果此代码放在window.onload = function() { ... }
,则不会考虑它,因为在加载窗口之前不会进行下载。
Here is the code that would actually work... 这是实际可行的代码......
var img = new Image;
img.src = 'http://www.gravatar.com/avatar/3535689c965d66db3d2a936ced96192a?s=32&d=identicon&r=PG';
img.alt = 'Example';
document.body.appendChild(img);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.