SlideShare a Scribd company logo
1 of 13
Lightning Page
Optimization & Best
Practices
Hyderabad, Salesforce Community
@gauravforc
e
Gaurav Jain
HYD, IN Admin Group
Lead, Lightning
Champion,
Tech Lead at
CriticalRiver
@SF_HYD_UG @HydSfdg @HyderabadWit @hydmcug
@gauravforce @RoshanKotla @SwatiTaunk @pradeepsfdc99
#TrailblazerCommunity #TeenKaTadka #LightningChampions
#HyderabadSalesforceCommunity
Sanket Kumar
Lightning Champion,
System Engineer at TCS
@sanket539
• 10 Ways to Increase Lightning Page Performance
• Best Practise and Limits
• Measuring Page Load Time
• Error Handling Best Practices for Lightning and Apex
• Lightning Component Code Review using Command Line Interface (CLI)
• Q&A
• Trailheadathon Registration and Instruction
• Trailheadathon
Agenda
10 Ways to Increase Lightning Page Performance
• Excessive fields clutter your page layouts, make your implementation difficult to maintain,
and increase page load time.
• Details Tab on Record Pages as Secondary Tab
• Replacing Related Lists with the Related List Quick Links Component
• Using Related List – Single Component
• Less Number of Lightning Components on Record Lightning Pages
• Set Component Visibility
• Move some Lightning components to the Tabs or Accordion Lightning component
• Taking out Inline Visualforce Pages and Report Chart from Page Layout
• News and Twitter components should be placed behind a tab
• Disable Debug Mode
Best Practise and Limits
• The number of fields should not exceed more than 150 on a page layout.
• 0-50 – GREEN
• 51-150 – AMBER
• > 150 – RED
• Too many components on a page can cause it to load slowly. You should keep below in
mind:-
• 0-15 – GREEN
• 16-20 – AMBER
• > 20 – RED
DEMO
Error Handling Best Practices for Lightning and Apex
Client-server communication overview
1. A Lightning component sends a request to its Apex
controller using a server-side action.
2. The controller processes the request. This can
trigger a server-side error (permission issue, invalid
query).
3. The controller sends a response to the Lightning
component.
4. The Lightning component processes the response
in a callback function. This can trigger a client-side
error (unexpected response).
This pattern can trigger two types of errors that
developers must handle: server-side and client-side
errors.
• If you process a failing server request
as is, a system exception is returned to
the Lightning component.
• Doing so is bad practice as this results
in a generic error message: “An
internal server error has occurred” or
“Sorry to interrupt”. This is not user-
friendly and provides no information
about the error. We all hate that. 🙁
What to avoid
Server-side errors handling
Using AuraHandledException
Basic error handling
1. Wrap the code that can trigger
exceptions in a try-catch block
2. Throw an AuraHandledException in the
catch block. This allows you to provide a
custom user-friendly error message.
Custom error handling
1. Create a simple wrapper class that can
hold the data.
2. Instantiate your custom class, serialize it
as JSON, then pass it to the
AuraHandledException.
3. client-side (Lightning controller or
helper), parse the error message string
as JSON, and access your custom error
data.
The AuraHandledException is sent back to the client with your custom message, and you’re
free to display it in the way you want using the Lightning Component framework.
Client-side errors handling
Basic error handling
Just like Apex Exceptions, JavaScript Errors enable you
to separate result values from errors when you call a
function. For instance, if you follow best practices and
let your helper do the heavy-lifting, you can write code
like this in your controller
Custom error handling
If a text message is not enough data to describe your
error, you can extend the JavaScript standard Error
type and create errors with custom attributes.
try {
// Call a function that may throws an Error
let value = helper.doSomethingThatMightFails();
// Process value if function succeeded
} catch (e) {
// Handle error
console.error(e);
}
// Declaring a custom error type
function MyCustomError(name, message, code) {
this.name = name;
this.message = message;
this.code = code;
this.stack = (new Error()).stack;
}
MyCustomError.prototype = Object.create(Error.prototype);
MyCustomError.prototype.constructor = MyCustomError;
You now know how to handle those different errors and how
to extend them to fit your needs.
Before Error Handling
After Error
Handling
Step 1: Heroku Installation
Download the Heroku toolbelt on your machine from the following link:
https://toolbelt.heroku.com/
Step 2: Install Salesforce Lightning CLI
Install Lightning CLI as a Heroku Toolbelt plugin. Once this is done, update the Heroku
Toolbelt to get the latest Lightning CLI rules.
heroku plugins:install salesforce-lightning-cli
Lightning Component Code Review using Command Line
Interface (CLI)
Step 3: Use Salesforce Lightning CLI
To display the Code Review on the command prompt in a text format, use:
heroku lightning:lint "F:ANTMalwarebytesBackup Partial 2-2-
2020auraAVLR_TaxExcempt"
Lightning Component Code Review using Command Line
Interface (CLI)
Lightning page optimization & best practices

More Related Content

What's hot

Will be an introduction to
Will be an introduction toWill be an introduction to
Will be an introduction toSayed Ahmed
 
Architecting single-page front-end apps
Architecting single-page front-end appsArchitecting single-page front-end apps
Architecting single-page front-end appsZohar Arad
 
Ajax Testing Approach
Ajax Testing ApproachAjax Testing Approach
Ajax Testing ApproachHarshJ
 
Ajax Testing Approach
Ajax Testing ApproachAjax Testing Approach
Ajax Testing ApproachHarshaVJoshi
 
WordPress and Client Side Web Applications WCTO
WordPress and Client Side Web Applications WCTOWordPress and Client Side Web Applications WCTO
WordPress and Client Side Web Applications WCTORoy Sivan
 
Five Ways to Scale your API Without Touching Your Code
Five Ways to Scale your API Without Touching Your CodeFive Ways to Scale your API Without Touching Your Code
Five Ways to Scale your API Without Touching Your Code3scale
 
Wordcamp Toronto Presentation
Wordcamp Toronto PresentationWordcamp Toronto Presentation
Wordcamp Toronto PresentationRoy Sivan
 
Build Your Own Instagram Filters
Build Your Own Instagram FiltersBuild Your Own Instagram Filters
Build Your Own Instagram FiltersTJ Stalcup
 
Lizards & Pumpkins Catalog Replacement at mm17de
Lizards & Pumpkins Catalog Replacement at mm17deLizards & Pumpkins Catalog Replacement at mm17de
Lizards & Pumpkins Catalog Replacement at mm17devinaikopp
 
Keeping Things Simple In A Growing AngularJS App.
Keeping Things Simple In A Growing AngularJS App.Keeping Things Simple In A Growing AngularJS App.
Keeping Things Simple In A Growing AngularJS App.Brandon Boswell, MBA
 
ASP.NET AJAX with Visual Studio 2008
ASP.NET AJAX with Visual Studio 2008ASP.NET AJAX with Visual Studio 2008
ASP.NET AJAX with Visual Studio 2008Caleb Jenkins
 
Apex code Benchmarking
Apex code BenchmarkingApex code Benchmarking
Apex code BenchmarkingAmit Chaudhary
 
Overview on ring central errors: part 2
Overview on ring central errors: part 2Overview on ring central errors: part 2
Overview on ring central errors: part 2Anirban Sen Chowdhary
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVCLearnNowOnline
 

What's hot (20)

Will be an introduction to
Will be an introduction toWill be an introduction to
Will be an introduction to
 
2310 b 04
2310 b 042310 b 04
2310 b 04
 
Architecting single-page front-end apps
Architecting single-page front-end appsArchitecting single-page front-end apps
Architecting single-page front-end apps
 
Ajax Testing Approach
Ajax Testing ApproachAjax Testing Approach
Ajax Testing Approach
 
Ajax Testing Approach
Ajax Testing ApproachAjax Testing Approach
Ajax Testing Approach
 
WordPress and Client Side Web Applications WCTO
WordPress and Client Side Web Applications WCTOWordPress and Client Side Web Applications WCTO
WordPress and Client Side Web Applications WCTO
 
Five Ways to Scale your API Without Touching Your Code
Five Ways to Scale your API Without Touching Your CodeFive Ways to Scale your API Without Touching Your Code
Five Ways to Scale your API Without Touching Your Code
 
CiviCRM API v3
CiviCRM API v3CiviCRM API v3
CiviCRM API v3
 
Wordcamp Toronto Presentation
Wordcamp Toronto PresentationWordcamp Toronto Presentation
Wordcamp Toronto Presentation
 
Build Your Own Instagram Filters
Build Your Own Instagram FiltersBuild Your Own Instagram Filters
Build Your Own Instagram Filters
 
Salesforce asynchronous apex
Salesforce asynchronous apexSalesforce asynchronous apex
Salesforce asynchronous apex
 
Lizards & Pumpkins Catalog Replacement at mm17de
Lizards & Pumpkins Catalog Replacement at mm17deLizards & Pumpkins Catalog Replacement at mm17de
Lizards & Pumpkins Catalog Replacement at mm17de
 
Keeping Things Simple In A Growing AngularJS App.
Keeping Things Simple In A Growing AngularJS App.Keeping Things Simple In A Growing AngularJS App.
Keeping Things Simple In A Growing AngularJS App.
 
ASP.NET AJAX with Visual Studio 2008
ASP.NET AJAX with Visual Studio 2008ASP.NET AJAX with Visual Studio 2008
ASP.NET AJAX with Visual Studio 2008
 
Apex code Benchmarking
Apex code BenchmarkingApex code Benchmarking
Apex code Benchmarking
 
SPSDC 2013 Building Solutions using SharePoint Timer Jobs
SPSDC 2013 Building Solutions using SharePoint Timer JobsSPSDC 2013 Building Solutions using SharePoint Timer Jobs
SPSDC 2013 Building Solutions using SharePoint Timer Jobs
 
Overview on ring central errors: part 2
Overview on ring central errors: part 2Overview on ring central errors: part 2
Overview on ring central errors: part 2
 
Ajax & ASP.NET 2
Ajax & ASP.NET 2Ajax & ASP.NET 2
Ajax & ASP.NET 2
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
SPSNJ 2013 Building Solutions using SharePoint TimerJobs
SPSNJ 2013 Building Solutions using SharePoint TimerJobsSPSNJ 2013 Building Solutions using SharePoint TimerJobs
SPSNJ 2013 Building Solutions using SharePoint TimerJobs
 

Similar to Lightning page optimization & best practices

London SF Developers: Custom Lightning Component Error Handling
London SF Developers: Custom Lightning Component Error HandlingLondon SF Developers: Custom Lightning Component Error Handling
London SF Developers: Custom Lightning Component Error HandlingRichard Clark
 
ASP.NET 05 - Exception Handling And Validation Controls
ASP.NET 05 - Exception Handling And Validation ControlsASP.NET 05 - Exception Handling And Validation Controls
ASP.NET 05 - Exception Handling And Validation ControlsRandy Connolly
 
Understanding progressive enhancement - yuiconf2010
Understanding progressive enhancement - yuiconf2010Understanding progressive enhancement - yuiconf2010
Understanding progressive enhancement - yuiconf2010Christian Heilmann
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for JavaLars Vogel
 
Client Side Performance In Web Applications
Client Side Performance In Web ApplicationsClient Side Performance In Web Applications
Client Side Performance In Web Applicationsvladungureanu
 
SCWCD : Handling exceptions : CHAP : 5
SCWCD : Handling exceptions : CHAP : 5SCWCD : Handling exceptions : CHAP : 5
SCWCD : Handling exceptions : CHAP : 5Ben Abdallah Helmi
 
Secure mvc application saineshwar
Secure mvc application   saineshwarSecure mvc application   saineshwar
Secure mvc application saineshwarSaineshwar bageri
 
Developing Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDeveloping Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDmitry Vinnik
 
Developing Java Web Applications In Google App Engine
Developing Java Web Applications In Google App EngineDeveloping Java Web Applications In Google App Engine
Developing Java Web Applications In Google App EngineTahir Akram
 
Magento's Imagine eCommerce Conference: Do You Queue?
Magento's Imagine eCommerce Conference: Do You Queue?Magento's Imagine eCommerce Conference: Do You Queue?
Magento's Imagine eCommerce Conference: Do You Queue?varien
 
Introduction to Magento Optimization
Introduction to Magento OptimizationIntroduction to Magento Optimization
Introduction to Magento OptimizationFabio Daniele
 
Beginning AngularJS
Beginning AngularJSBeginning AngularJS
Beginning AngularJSTroy Miles
 
Ajax Performance
Ajax PerformanceAjax Performance
Ajax Performancekaven yan
 
20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...
20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...
20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...Craeg Strong
 
Server side programming bt0083
Server side programming bt0083Server side programming bt0083
Server side programming bt0083Divyam Pateriya
 
The Basics Angular JS
The Basics Angular JS The Basics Angular JS
The Basics Angular JS OrisysIndia
 
learn mvc project in 7 day
learn mvc project in 7 daylearn mvc project in 7 day
learn mvc project in 7 dayQuach Long
 

Similar to Lightning page optimization & best practices (20)

London SF Developers: Custom Lightning Component Error Handling
London SF Developers: Custom Lightning Component Error HandlingLondon SF Developers: Custom Lightning Component Error Handling
London SF Developers: Custom Lightning Component Error Handling
 
Presemtation Tier Optimizations
Presemtation Tier OptimizationsPresemtation Tier Optimizations
Presemtation Tier Optimizations
 
ASP.NET 05 - Exception Handling And Validation Controls
ASP.NET 05 - Exception Handling And Validation ControlsASP.NET 05 - Exception Handling And Validation Controls
ASP.NET 05 - Exception Handling And Validation Controls
 
Understanding progressive enhancement - yuiconf2010
Understanding progressive enhancement - yuiconf2010Understanding progressive enhancement - yuiconf2010
Understanding progressive enhancement - yuiconf2010
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
 
Client Side Performance In Web Applications
Client Side Performance In Web ApplicationsClient Side Performance In Web Applications
Client Side Performance In Web Applications
 
SCWCD : Handling exceptions : CHAP : 5
SCWCD : Handling exceptions : CHAP : 5SCWCD : Handling exceptions : CHAP : 5
SCWCD : Handling exceptions : CHAP : 5
 
Top 5 React Performance Optimization Techniques in 2023
Top 5 React Performance Optimization Techniques in 2023Top 5 React Performance Optimization Techniques in 2023
Top 5 React Performance Optimization Techniques in 2023
 
Php exceptions
Php exceptionsPhp exceptions
Php exceptions
 
Secure mvc application saineshwar
Secure mvc application   saineshwarSecure mvc application   saineshwar
Secure mvc application saineshwar
 
Developing Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDeveloping Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptx
 
Developing Java Web Applications In Google App Engine
Developing Java Web Applications In Google App EngineDeveloping Java Web Applications In Google App Engine
Developing Java Web Applications In Google App Engine
 
Magento's Imagine eCommerce Conference: Do You Queue?
Magento's Imagine eCommerce Conference: Do You Queue?Magento's Imagine eCommerce Conference: Do You Queue?
Magento's Imagine eCommerce Conference: Do You Queue?
 
Introduction to Magento Optimization
Introduction to Magento OptimizationIntroduction to Magento Optimization
Introduction to Magento Optimization
 
Beginning AngularJS
Beginning AngularJSBeginning AngularJS
Beginning AngularJS
 
Ajax Performance
Ajax PerformanceAjax Performance
Ajax Performance
 
20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...
20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...
20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...
 
Server side programming bt0083
Server side programming bt0083Server side programming bt0083
Server side programming bt0083
 
The Basics Angular JS
The Basics Angular JS The Basics Angular JS
The Basics Angular JS
 
learn mvc project in 7 day
learn mvc project in 7 daylearn mvc project in 7 day
learn mvc project in 7 day
 

Recently uploaded

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 

Recently uploaded (20)

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 

Lightning page optimization & best practices

  • 1. Lightning Page Optimization & Best Practices Hyderabad, Salesforce Community @gauravforc e Gaurav Jain HYD, IN Admin Group Lead, Lightning Champion, Tech Lead at CriticalRiver @SF_HYD_UG @HydSfdg @HyderabadWit @hydmcug @gauravforce @RoshanKotla @SwatiTaunk @pradeepsfdc99 #TrailblazerCommunity #TeenKaTadka #LightningChampions #HyderabadSalesforceCommunity Sanket Kumar Lightning Champion, System Engineer at TCS @sanket539
  • 2. • 10 Ways to Increase Lightning Page Performance • Best Practise and Limits • Measuring Page Load Time • Error Handling Best Practices for Lightning and Apex • Lightning Component Code Review using Command Line Interface (CLI) • Q&A • Trailheadathon Registration and Instruction • Trailheadathon Agenda
  • 3. 10 Ways to Increase Lightning Page Performance • Excessive fields clutter your page layouts, make your implementation difficult to maintain, and increase page load time. • Details Tab on Record Pages as Secondary Tab • Replacing Related Lists with the Related List Quick Links Component • Using Related List – Single Component • Less Number of Lightning Components on Record Lightning Pages • Set Component Visibility • Move some Lightning components to the Tabs or Accordion Lightning component • Taking out Inline Visualforce Pages and Report Chart from Page Layout • News and Twitter components should be placed behind a tab • Disable Debug Mode
  • 4. Best Practise and Limits • The number of fields should not exceed more than 150 on a page layout. • 0-50 – GREEN • 51-150 – AMBER • > 150 – RED • Too many components on a page can cause it to load slowly. You should keep below in mind:- • 0-15 – GREEN • 16-20 – AMBER • > 20 – RED
  • 6. Error Handling Best Practices for Lightning and Apex Client-server communication overview 1. A Lightning component sends a request to its Apex controller using a server-side action. 2. The controller processes the request. This can trigger a server-side error (permission issue, invalid query). 3. The controller sends a response to the Lightning component. 4. The Lightning component processes the response in a callback function. This can trigger a client-side error (unexpected response). This pattern can trigger two types of errors that developers must handle: server-side and client-side errors.
  • 7. • If you process a failing server request as is, a system exception is returned to the Lightning component. • Doing so is bad practice as this results in a generic error message: “An internal server error has occurred” or “Sorry to interrupt”. This is not user- friendly and provides no information about the error. We all hate that. 🙁 What to avoid
  • 8. Server-side errors handling Using AuraHandledException Basic error handling 1. Wrap the code that can trigger exceptions in a try-catch block 2. Throw an AuraHandledException in the catch block. This allows you to provide a custom user-friendly error message. Custom error handling 1. Create a simple wrapper class that can hold the data. 2. Instantiate your custom class, serialize it as JSON, then pass it to the AuraHandledException. 3. client-side (Lightning controller or helper), parse the error message string as JSON, and access your custom error data. The AuraHandledException is sent back to the client with your custom message, and you’re free to display it in the way you want using the Lightning Component framework.
  • 9. Client-side errors handling Basic error handling Just like Apex Exceptions, JavaScript Errors enable you to separate result values from errors when you call a function. For instance, if you follow best practices and let your helper do the heavy-lifting, you can write code like this in your controller Custom error handling If a text message is not enough data to describe your error, you can extend the JavaScript standard Error type and create errors with custom attributes. try { // Call a function that may throws an Error let value = helper.doSomethingThatMightFails(); // Process value if function succeeded } catch (e) { // Handle error console.error(e); } // Declaring a custom error type function MyCustomError(name, message, code) { this.name = name; this.message = message; this.code = code; this.stack = (new Error()).stack; } MyCustomError.prototype = Object.create(Error.prototype); MyCustomError.prototype.constructor = MyCustomError;
  • 10. You now know how to handle those different errors and how to extend them to fit your needs. Before Error Handling After Error Handling
  • 11. Step 1: Heroku Installation Download the Heroku toolbelt on your machine from the following link: https://toolbelt.heroku.com/ Step 2: Install Salesforce Lightning CLI Install Lightning CLI as a Heroku Toolbelt plugin. Once this is done, update the Heroku Toolbelt to get the latest Lightning CLI rules. heroku plugins:install salesforce-lightning-cli Lightning Component Code Review using Command Line Interface (CLI)
  • 12. Step 3: Use Salesforce Lightning CLI To display the Code Review on the command prompt in a text format, use: heroku lightning:lint "F:ANTMalwarebytesBackup Partial 2-2- 2020auraAVLR_TaxExcempt" Lightning Component Code Review using Command Line Interface (CLI)