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?
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.
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.
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.
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:...">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With