Simple to ask, possible hard to answer. I have written a Lightning app to create forms which works a bit like the page builder in LEX itself. It saves the form description into JSON, and then dynamically creates all of the components from the JSON description upon load.
Since Winter 18, the performance has dropped dramatically. So, I want to know if there are some things that I should be taking into consideration when calling
$A.createComponents and/or what is it actually doing that is taking all the time?
In my app, I'm calling
$A.createComponents with 1,311 components in the array to create. That takes about 8s to run. Client caching is enabled and I'm using
<aura:dependency> to declare every type I'm going to create.
One obvious change I could make is to break those 1,311 components up into chunks and load them progressively. Either at arbitrary limits, or by getting some components to load themselves e.g. create a tabbed section of the form on load, but let the tabbed section load its own children in another call to $A.createComponents once we have something on the screen. That's going to be a fair amount of messing around and introduces the complexity of what to do when the user starts interacting with the form before it has all loaded. So, I'd rather not.
One thing I've already tried is trimming down the number of components inside the ones I'm creating e.g. by using
$A.createComponents again inside the children instead of
<aura:if> as suggested here: https://www.codescience.com/blog/2017/performance-tuning-for-lightning-components-with-large-volume-subcomponents That definitely reduced the number of components by the time it had fully loaded (as measured by
$A.componentService.countComponents()), but hasn't noticably reduced the load-time.
I've tried profiling with Lightning Inspector and Chrome Performance tab (on examples large and small), but a great chunk of the time is inside aura code, not mine, so that hasn't really helped.