是什么阻止 HTML 页面利用渐进式渲染?
我注意到有些页面几乎立即开始渲染,而另一些页面有时必须等到许多或所有资源(javascript、图像、css)下载完毕。最糟糕的情况似乎是大页面、连接或服务器速度慢。我正在查看的一个特定页面几乎有 2 MB,其中包含 30 个不同的 .js 文件、十几个 .css 文件和 80 个图像。
我知道 http://developer.yahoo.com/performance/rules.html 中的建议,但是什么会阻止浏览器在下载最后一个元素之前尝试渲染页面呢?
I've notice that some pages begin to render almost immediately, while others sometime have to wait until many or all of the resources (javascript, image, css) have been downloaded. The worst case seems to be for a large page, on a slow connection or server. One specific page I'm looking at comes out to almost 2 MB, with 30 different .js files, a dozen .css files, and 80 image.
I'm aware of the suggestions at http://developer.yahoo.com/performance/rules.html, but what would be preventing the browser from attempting to render the page until the last element has been downloaded?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
发生这种情况的原因有很多。我最常见的是大桌子。
例如,Internet Explorer 不喜欢在完成加载之前呈现表格。
不过,每个浏览器在渲染仍在下载的内容方面都略有不同。
There are a handful of reasons why this may happen. The most common that I see are large tables.
For example, Internet Explorer doesn't like to render a table until it is finished loading.
Each browser is a bit different though, in how they render things that are still downloading.
一般规则是不要使用有关结构的标签来影响布局。通过页面开头的样式,渲染引擎知道它必须做什么来渲染页面的特定部分,但它总是必须等待部分下载才能知道如何正确渲染它。
考虑到这一点:
如今使用的庞大 JavaScript 库的不同之处在于它们只需要加载(和缓存)一次。
The general rule is to not use tags about structure to affect layout. With the styles at the start of a page a rendering engine knows what it has to do to render a certain part of the page, but it always has to wait for a part to download to know how to render it properly.
With that in mind:
The huge JavaScript libraries in use today are different in that they only need to be loaded (and cached) once.