简体   繁体   中英

Will using an Iframe for another file on your server make the current page loading faster than just loading it directly on the page?

So I have a webpage index.php and it pulls in a Facebook post with the embedded post method that facebook provides. The problem is that it takes a ridiculous amount of time for that content to load. My idea was to load that embedded facebook post on another page like post.php and JUST that content itself with nothing else on the page. Then load it onto the page that I want to use it on using IFrames like so:

<iframe class="fb-content-frame" width="350" height="550" scrolling="no" seamless="seamless" frameborder="0" src="http://mywebsite.com/test/post.php" allowfullscreen></iframe>

So now my question is:

Will using this method improve the load time of my main page (index.php) then just loading the Facebook content on the page itself?

If I am not mistaken then an <iframe> should be treated just like an asset such as CSS, JS, and image files.

The issue to watch out for is that web browsers generally have a limit on concurrent downloads so if your main page has 10 images, 5 above the <iframe> and 5 below it then the <iframe> can potentially delay the other images if the <iframe> has 50 images to load.

However, if your <iframe> is merely taking forever then I think the remaining 5 images should load no problem.

It is very possibly to solve this much more gracefully with AJAX loading of this content because you will have much more granular control.

In my experience, it will actually slow the load time for the first time as it has to load the iframe and then the content inside it. The speed increase comes when you want to reload the content within the iframe, but not reload the layout, in which case the load is faster as the page is loading less at once.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM