You can use the load
event that will be triggered when all resources are loaded:
const iframe = document.getElementById('iframe');
window.addEventListener("load", function(event) {
console.log('Está tudo carregado');
iframe.style.display = 'block';
});
iframe {
display: none;
}
<iframe id="iframe" width="560" height="315" src="https://www.youtube.com/embed/gQghzrNo68s"frameborder="0" allowfullscreen></iframe>
DOCS
To trigger the event when only partial HTML loading occurs, DOCS :
The DOMContentLoaded event fires when the initial HTML document has been completely loaded and parsed, without waiting for style sheets, images, and subframes to terminate loading.
You do:
document.addEventListener("DOMContentLoaded", function(event) {
console.log("DOM completamente carregado e analisado");
iframe.style.display = 'block';
});