8

In the LWC documentation for debug mode it states (emphasis mine):

By default, the framework runs in production mode. This mode is optimized for performance. Framework code is optimized and “minified” to reduce the size of the JavaScript code

The docs seem to imply that there is more to the optimization beyond just minification. What kind of optimization are we talking about?

The closest I've found is in the section on bundling in the documentation for the LWC compiler which says that:

The final phase of the compilation pipeline is bundling. During bundling, Rollup will ‘statically analyze and optimize the code you are importing, and will exclude anything that isn't actually used. This allows you to build on top of existing tools and modules without adding extra dependencies or bloating the size of your project’. The end result of the bundler is a single javascript file in a specified format - ‘amd’ by default.

Is that the kind of optimization that the LWC docs are referring to?

2 Answers 2

2

In order to improve the developer experience, the LWC engine contains code producing warning and error for common mistakes. On top of increasing the size of the LWC engine, some of those warnings and errors are expensive to compute at runtime.

When running in production mode, on top of minifying the code, all the guardrails warnings and error messages are stripped in the generated output. The non-production code can be found inside process.env.NODE_ENV !== 'production' if blocks in the LWC repository. Last time I checked, the production version of the LWC engine is ~5x faster than the debug version.

0

If we want GoogleSpeed Green Area (> 90%). You have to use Static Resources with OpenSource LWC or React, Angular and etc.

Because all Salesforce optimizations use only minify and compress scripts. Performance is awful.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .