当 DOM 元素在屏幕外渲染时,浏览器会执行哪些优化?
我控制在另一个域上呈现的 iframe。是否有明确的方法来判断此 iframe 是在父页面的折叠上方还是下方呈现?显然,由于 同源策略 限制,我无法访问父 DOM。
例如,我尝试测量 canvas
或 VML
标记上的渲染速度,希望当标记不在屏幕上时渲染速度会更快。但这不起作用——没有明显的速度差异。 DOM 操作也是如此 - 似乎没有办法区分折叠下方或上方的回流/重绘操作。
闪光灯呢?我没有太多经验,但是可以检查一下浏览器渲染 Flash 操作的速度吗?或者 Flash 是否有任何 DOM 标准之外的“不可见”事件?
I control an iframe being rendered on another domain. Is there a clear way of telling whether this iframe is being rendered above or below the fold on the parent page? Obviously, I can't access the parent DOM because of the same origin policy restriction.
For example, I tried measuring the speed of rendering on a canvas
or VML
tag, hoping it would be faster when the tag isn't on screen. This didn't work - there was no discernable speed difference. Ditto for DOM manipulation - there doesn't seem to be a way to differentiate between reflow/repaint operations below or above the fold.
What about flash? I don't have much experience, but could one check how quickly a browser renders flash operations? Or does flash have any 'onvisible' events outside of the DOM standard?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不这么认为。
尽管您可以使用 url 参数(可以通过嵌入广告的 javascript 设置)到页面上的偏移量,但同源策略限制会阻止这种情况发生。
I don't think so.
The same origin policy restriction prevents that, although you can use url parameters, which can be set by the javascript embedding the ad, to the offset on the page.
SoundManager2 的作者 Scott Schiller 表示,根据 Flash 电影是否在屏幕上显示,JS->Flash 通信桥的延迟会略有不同。也就是说,当它不在屏幕上时,它会变慢。
According to the author of SoundManager2 Scott Schiller, there's a slight difference in the latency of the JS->Flash communication bridge depending on whether the flash movie is on screen or not. That is, it's slower when it is not on screen.
这实际上因浏览器而异,因为不同的浏览器与 Flash 插件的交互方式不同。我能找到的最精确的解释是旧的 已连接的像素帖子。
在撰写本文时,Firefox 直到 Flash 对象在页面上滚动时才初始化它。另一方面,IE 在 Stage 元素滚动到视图中时调整其大小。没有给出浏览器、Flash 或操作系统的版本,因此自该测试以来这可能已发生变化。
简而言之,我需要制作一个 Flash 对象并使用它,观察各种事件。
This really varies by-browser, as different browsers interact with the Flash plugin differently. The most precise explanation I could find is on an old connectedpixel post.
At the point of writing, Firefox didn't init a flash object until it was scrolled on page. IE, on the other hand, resized the Stage element when it scrolled into view. No versions of browser, Flash, or OS are given, so this may have changed since that test.
In short, I need to make a flash object and play with it, watching for various events.