Should I load a hidden iframe in the beginning?

不羁岁月 提交于 2020-01-15 18:18:31

问题


I'm testing the speed of my site, mostly for the purpose of high ranking in Google.

So I'm using this site: http://www.webpagetest.org/compare

Everything works really fast, except a page I'm displaying in an iframe. The images in this page take a really long time to load, mostly because they are taken from a different, slower, website. In my test all the site loaded under 3 seconds, except for these images who took almost 10 seconds.

So here's the thing. This iframe is actually hidden until a person clicks on a link. So it is possible for me not to load this iframe until the user clicks. The question is: should I? Or in more detail, these are my questions:

  1. Does the loading of hidden iframe and images really affects the page load time that google measures?
  2. 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).

回答1:


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

Yes it affects it

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).

No, this is not a good practice. You should do something else.

What? See my logic below.

Load your page including your iframe but with NO src value, so it loads really quick. And onLoad of the page, just call a javascript function that will load the iframe in the backround without the user (or google) noticing that something is still loading



来源:https://stackoverflow.com/questions/12351360/should-i-load-a-hidden-iframe-in-the-beginning

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!