How to preload iframes

NBI picture NBI · Sep 13, 2015 · Viewed 18.4k times · Source

I am having multiple iframes to display data in a page.
I want to preload the next 3 iframes while viewing current view. am doing like the below:

I will hide the all iframes and set the source for it.
When I clicked on a particular view I will show it and in background I will load the next 3 iframes.
while doing this, some loading is showing in browser tab and it doesn't look good at all.

How to get rid of this loading in browser for usability?

Answer

monkeythedev picture monkeythedev · Sep 8, 2017

I've answered a similar question there:

https://stackoverflow.com/a/46121439/1951947

In your case it would be:

<link rel="preload" href="https://example.com/widget.html" as="document">

and then you can use your iframe as usual:

<iframe src="https://example.com/widget.html"></iframe>