Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is an event fired when an HTML import finishes loading?

So I am loading a load screen in my app. Then I load my custom elements through HTML imports by making a link element in JavaScript. I need to know when this HTML import has finished loading to display content to the user. Do HTML imports fire an event when the download finishes?

like image 671
Akheel K M Avatar asked Mar 15 '23 14:03

Akheel K M


1 Answers

When the HTML import has finished loading, it fires an event called HTMLImportsLoaded. I'd recommend you to rely on this event to get a consistant behavior across the different browsers.

window.addEventListener( "HTMLImportsLoaded", function ()
{
    //HTML Imports are loaded
} )

On HTML Imports, read this to understand the difference between onload, HTMLImportsLoaded and WebComponentsReady : http://webcomponents.org/polyfills/html-imports/

like image 164
Supersharp Avatar answered Mar 19 '23 13:03

Supersharp