You need to sign in to do that
Don't have an account?
Curiosity
Is there any way to declare the sequence in which Lightning Components are initialized during page load?
What is the order of initialization of Lightning components?
I am building a Customer Community using the Napili Template. I have customized the home page by adding a few custom-built Lightning Components. I want to ensure that all the external JavaScript libraries are loaded last (lazy loading) so that the end-user does not have to stare at a blank page while all those libraries get loaded. For this I thought putting the <ltng:require> tags in my footer will work because I assumed that the components are initialized in order from top to bottom of the page and the Footer will initialize (i.e. fire the init event) all last since I had placed it at the very bottom of the page BUT in practice I am observing that many times the footer initializes before the other components do.
I am building a Customer Community using the Napili Template. I have customized the home page by adding a few custom-built Lightning Components. I want to ensure that all the external JavaScript libraries are loaded last (lazy loading) so that the end-user does not have to stare at a blank page while all those libraries get loaded. For this I thought putting the <ltng:require> tags in my footer will work because I assumed that the components are initialized in order from top to bottom of the page and the Footer will initialize (i.e. fire the init event) all last since I had placed it at the very bottom of the page BUT in practice I am observing that many times the footer initializes before the other components do.
For including scripts use ltng:require
<ltng:require styles=""
scripts="{}" afterScriptsLoaded="{!c.scriptsLoaded}"/>
In the afterScriptsLoaded method, change the variable used in aura:if to true.
Hope this helps.
We know js executes the code asynchronously so we cannot judge which method will execute first.
So you can also add the code of doInit(Handler) in the method which you use in afterScriptLoaded if you want that your page get loads after the script.
Hope, this will help you in solving the issue.
Thanks