Optimizing JavaScript in Lightning Components
The Lightning Component framework uses JavaScript on the frontend. Hence, anything that improves JavaScript performance should be considered.
Some of these techniques include the following:
- Image optimization, by using
Lightning:icon
andLightning:buttonIcon
. - Using minified JavaScript bundle if you are using any third-party JavaScript library for production releases. It is recommended not to use any third-party libraries if the framework can do the work for you.
- Using a bundler, such as Webpack Bundler with CSS Purify to minify JavaScript and remove unnecessary selectors.
- Using
console.time()
,console.timeEnd
, and performance (https://developer.mozilla.Org/en-US/docs/Web/API/Performance) APIs to gather metrics to uncover performance issues.