Salesforce Menu

Best Practices

These are some of the common best practices used in aura component development in order to ensure good framework performance :

  1. 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.
  2. Try and use Lightning Data Service to save apex calls for performing DML operations whenever possible.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. Try to avoid using too many alert and console log statements as they decrease the page performance.
  9. Try and implement caching to improve your apex calls with a “cacheable=true” statement if the use case supports it.
  10. Try and avoid using third party scripts like jQuery unnecessarily because most of the same features are present in the standard lightning component framework.
  11. SLDS provides great standard icons for most of the common use cases, so do not use custom icons unless required.
  12. If you need to use third party CSS or libraries, make sure to use the minified versions.
Subscribe Now