wordpress.com - saramorgan.net @sarahasnolimits at ......top 5 debugging tips # 1 - check debug mode...

29
Lightning Performance and Debugging Tips for Developers Sara Morgan Nettles Lead Technical Curriculum Engineer at Salesforce @SaraHasNoLimits http://saramorgan.net

Upload: others

Post on 15-Oct-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

Lightning Performance and Debugging Tips for Developers

Sara Morgan NettlesLead Technical Curriculum Engineer

at Salesforce@SaraHasNoLimits

http://saramorgan.net

Page 2: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

Round of applause for our Platinum Sponsors!

Page 3: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

Round of applause for our Gold Sponsors!

Page 5: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

Agenda

• Top 5 Performance Tips

• Top 5 Debugging Tips

• Demo of Using Lightning Inspector

• Questions

Page 6: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

Top 5 Performance Tips

Page 7: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

# 1 - Check Component Caching Setting

To Enable/Disable Component Caching:1. From Setup, go to Session Settings.2. Select/Deselect the Enable secure and

persistent browser caching to improve performance checkbox.

3. Click Save.

May Want to Disable for Development

Definitely Enable for Production

Page 8: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

# 1 - Check Component Caching Setting

For SalesforceDX developers, you can disable the setting automatically for scratch orgs with the following line in your config file

Page 9: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

# 2 - <aura:if> for Conditional Rendering

Don’t Use this

<div aura:id=“submitBtn” class=“slds-hide”>

<lightning:button label="Submit"

onclick="{!c.newRecord}" />

</div>

cmp.find(“submitBtn").toggleClass(!isVisible, "slds-hide");

Page 10: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

# 2 - <aura:if> for Conditional Rendering

Use this instead

<aura:if isTrue="{!v.isVisible}">

<lightning:button label="Submit"

onclick="{!c.newRecord}" />

</aura:if>

https://bit.ly/2Lf3YRp for more info

Page 11: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

# 3 - Limit Data Returned

• Make sure SELECT statement only returns data you

absolutely need

• Use the LIMIT clause to limit # of rows returned

• Consider adding pagination to lists of data

• https://bit.ly/2J89QiP for more info

Page 12: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

# 4 - Use the Lightning Data ServiceAKA: The Standard Controller for Lightning

Benefits include:

No APEX or SOQL needed

FLS and CRUD security built-in

Auto-notify on record changes

Offline access for Salesforce Mobile

Single Request and Cached Response

Page 13: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

# 4 - Use the Lightning Data Service

Lightning Component

Lightning Component

Lightning Data

ServiceController

Shared Data

Cache

Salesforce

<force:recordData>

Lightning Component

<force:recordData>

<force:recordData>

Page 14: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

# 4 - Use the Lightning Data Service<force:recordData aura:id="raceRecordCreator"

layoutType="FULL"

targetRecord="{!v.newRaceRec}"

targetFields="{!v.newRace}"

targetError="{!v.errorMsg}" />

https://bit.ly/2xGxKfS for more info

Page 15: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

# 5 - Use Storable Actions When Possible

Notice the Pagination

Page 16: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

# 5 - Use Storable Actions When Possible

var action = component.get('c.getRacesDB');

action.setStorable();

action.setCallback(this, function(response) {

// Code here to handle the response

}

$A.enqueueAction(action);

Caching in a Single Line of Code

https://bit.ly/2wdRHFR for more info

Page 17: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

Top 5 Debugging Tips

Page 18: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

# 1 - Check Debug Mode SettingONLY Enable for Development or Sandboxes

Make sure you Disable for Production

To Enable/Disable Debug Mode:1. From Setup, go to Lightning Components.2. Select/Deselect the Enable Debug Mode

checkbox.3. Click Save.

Page 19: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

# 2 - Use the Salesforce CLI Linting Tool

Salesforce DX includes a linting tool you can use during development to avoid Locker Service conflicts and anti-patterns

https://sforce.co/2LW7mSd for more about the Salesforce CLI

Page 20: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

# 2 - Use the Lightning Linter Service?

https://lightning-linter.herokuapp.com/

Page 21: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

# 3 - Use debugger and Dev Tools

https://bit.ly/2k498lH for more info

Page 22: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

# 4 - Use Lightning Testing Service

https://sforce.co/2kUXegv for more info

Set of tools used to create test suites in Jasmine or Mocha

Currently in Pilot

Page 23: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

# 4 - Use Lightning Testing Service

https://bit.ly/2xQEIPs for tips on my blog

Page 24: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

# 5 - Use the Lightning Inspector Plugin

Page 25: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

# 5 - Use the Lightning Inspector Plugin

https://sforce.co/2jNXJr2 for more info

Page 26: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

Demo Time

Page 27: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

Check Out These Amazing Trails:

-Lightning Component Tips and Gotchas-Lightning Data Service Basics-Lightning Component Basics

Page 28: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

Sara Morgan Nettleshttp://saramorgan.net@SaraHasNoLimits

Thank You!

Page 29: WordPress.com - saramorgan.net @SaraHasNoLimits at ......Top 5 Debugging Tips # 1 - Check Debug Mode Setting ONLY Enable for Development or Sandboxes Make sure you Disable for Production

Happy trails ‘til next year, y’all!