html - 我应该在开始时加载隐藏的 iframe 吗?

标签 html pagespeed

我正在测试我网站的速度,主要是为了在 Google 中获得高排名。

所以我正在使用这个网站:http://www.webpagetest.org/compare

一切都运行得非常快,除了我在 iframe 中显示的页面。此页面中的图像需要很长时间才能加载,主要是因为它们是从另一个速度较慢的网站获取的。在我的测试中,除了这些花费了近 10 秒的图像之外,所有网站的加载时间都在 3 秒内。

所以事情是这样的。该 iframe 实际上是隐藏的,直到有人单击链接为止。所以我可以在用户点击之前不加载这个 iframe。问题是:我应该吗?或者更详细地说,这些是我的问题:

  1. 加载隐藏的 iframe 和图像真的会影响 Google 测量的页面加载时间吗?
  2. 为了加快页面加载速度,让用户在单击链接时等待数据是否有意义(实际上,我正在使用 Google PageSpeed 服务,因此页面在 iframe 加载之前就可以正常显示和工作)满载)。

最佳答案

Does the loading of hidden iframe and images really affects the page load time that google measures?

是的,它会影响它

Does it make sense to make the user wait for the data when he clicks the link just for the sake of faster page load (actually, I'm using Google PageSpeed service, so the page shows and works fine before the iframe is fully loaded).

不,这不是一个好的做法。你应该做点别的事。

什么?请参阅下面我的逻辑。

加载您的页面,包括 iframe,但没有 src 值,因此加载速度非常快。在页面的 onLoad 中,只需调用一个 javascript 函数,该函数将在后台加载 iframe,而用户(或谷歌)不会注意到某些内容仍在加载

关于html - 我应该在开始时加载隐藏的 iframe 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12351360/

相关文章:

html - CSS 边框 : difference in Firefox/Chrome

javascript - jQuery 在点击和滚动后闪烁一个元素

html - 内联 Critical CSS 值吗?

ruby-on-rails - 我应该关心 Newrelic Rails 应用程序中的 DOM 处理时间吗?

javascript - 大型 HTML 文档对页面速度有什么好处吗?

javascript - jQuery如何找到图像上层元素

javascript - 下划线代码在网页上不显示任何内容

html - 纯 css 无法正确加载到 Ruby on Rails 中

css - 如何将 wordpress 模板 style.css 文件移动到另一个文件夹中?

php - 正在使用 "require_once "影响网站速度