ltng:require afterScriptsLoaded will run after dom was fully loaded. Why?

I mean where is it documented?

I saw it, for example, here

As per @TrevorBliss comments , adding afterScriptsLoaded to the ltng:require is sufficient which means there's no need for the renderer.

But I was not able to find any documentations, could someone please, explain is it really so and if it is, then where is it written. Thank you.


It's mentioned in this documentation:

The afterScriptsLoaded action in the client-side controller is called after the scripts are loaded and the component is rendered. Don't use the init event to access scripts loaded by <ltng:require>. These scripts load asynchronously and are most likely not available when the init event handler is called.

As you can see, the scripts are loaded after the components are rendered. After rendering, the DOM is already built. The "most likely not available" part means that the same script on a different component might be available in some rare, esoteric edge cases, but you shouldn't depend on it. This will probably only apply to dynamically created components where at least one prior component has already loaded the scripts, but it should not be depended upon.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.