These are some of the common best practices used in aura component development in order to ensure good framework performance :
- Do not make multiple apex calls when handling the ‘init’ method, there should only be a single apex method call in the ‘init’ event handler. This is to make sure that we call only a single apex method when the page loads.
- Try and use Lightning Data Service to save apex calls for performing DML operations whenever possible.
- Try to put logic like data sorting etc. in the client side javascript controller and only make an apex call when you absolutely need to.
- Use SLDS (Salesforce Lightning Design System) to build out your component UI to ensure it is dynamic and follows the standard lightning UI look and feel.
- Use conditional rendering with the ‘’ tag instead of the ‘<render:if>’ tag because the aura:if works by removing the element from the markup, whereas the render:if works by applying CSS to hide and show markup.
- Enabling debug mode for your aura components can slow down the framework, so do not keep it turned on in production unless required for some debugging.
- Use unbound expression like ‘{#v.text}’ instead of using bound expression {!v.text}’ wherever we don’t need to sync the attribute value after the attribute has been rendered on the markup.
- Try to avoid using too many alert and console log statements as they decrease the page performance.
- Try and implement caching to improve your apex calls with a “cacheable=true” statement if the use case supports it.
- Try and avoid using third party scripts like jQuery unnecessarily because most of the same features are present in the standard lightning component framework.
- SLDS provides great standard icons for most of the common use cases, so do not use custom icons unless required.
- If you need to use third party CSS or libraries, make sure to use the minified versions.