问题
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:
- 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).
回答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