Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load an iframe asynchronously

I have a webpage with an <iframe> pointing to another website. I don't want this to block the loading of the rest of the page. Is there a way to load it asyncrounously?

like image 582
leora Avatar asked Jan 22 '10 01:01

leora


People also ask

Do iFrames load asynchronously?

Show activity on this post. One problem we had was that while iframes already do load asynchronously, the main page will not fire OnLoad until the iframe has finished loading too.

How check iframe is loaded or not in JavaScript?

To check if iframe is loaded or it has a content with JavaScript, we can set the iframe's onload property to a function that runs when the iframe is loaded. document. querySelector("iframe"). onload = () => { console.

How do I stop an iframe from loading?

the pure js version: document. getElementsByTagName('iframe')[0]. src = "about:blank"; remember you can't use the frames[0] because it gives you the window inside the iframe, not the iframe element in your page with the src attribute.


1 Answers

It shouldn't block. If you want the main page to fully load first (eg, main page's images before iframe content) then you'll have to use a bit of javascript to set the url of the iframe, like <body onload="javascript:...">

like image 92
Steve Cooper Avatar answered Oct 11 '22 06:10

Steve Cooper