Lightning Component Best Practices

Lightning Component Best Practices

1. Do not put so many console logs.

2. Make use of SLDS ( Salesforce Lightning Design System) for consistent UI design.

3. Make use of Lightning Data Services to avoid Server calls for DML operations, navigation, etc.

4. Don’t make a call to the server to filter or sort data you already have at the client-side.

5. Use Unbound expression if data across components are not required to be in Sync.

6. Before you decide to use a third-party library in a Lightning component, you should reevaluate if you really need that library. DOM manipulation libraries (like jQuery) and UI libraries (like Bootstrap or jQuery UI) in particular may no longer be needed when working with the Lightning Component Framework.

7. When possible, use the (sprite-based) Lightning Design System icons (using <lightning:icon> and <lightning:buttonIcon>) instead of custom icons.

8. Salesforce is slower for users who have debug mode enabled. So, do not enable in Production.

Check the below link for Lightning Component Best Practices from Salesforce

Events Best Practices – https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/events_best_practices.htm?search_text=best%20practice

Best Practices for Conditional Markuphttps://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_conditional_markup.htm?search_text=best%20practice

Best Practices for Error Handling https://developer.salesforce.com/blogs/2017/09/error-handling-best-practices-lightning-apex.html

Leave a Reply