目录

On-Demand Injection and Render-Time Injection

During the startup of an atomic service, code injection is a significant bottleneck. The more code that is injected, the more memory it consumes and the longer it takes.

This issue can be addressed by using on-demand injection and render-time injection, which help reduce both the time and memory required for code injection.

Add the following content to app.json:

{
  "lazyCodeLoading": "requiredComponents"
}

Since ASCF runtime 1.0.13, only necessary code is injected for atomic services to reduce the startup time and memory usage at runtime.

On-Demand Injection

Version restrictions:

Generally, when an atomic service starts, all pages and components on which the startup page depends are injected all at once, including pages and custom components that are not accessed or used yet. In addition, the JS code for all these pages and components is executed immediately. This means a large amount of unused code is injected and executed at runtime, increasing the injection duration and memory usage.

Precautions

Render-Time Injection

Version restrictions:

When on-demand injection is enabled, you can use render-time injection to specify certain custom components to be injected only when they are actually rendered, rather than during the atomic service startup.

When lazyCodeLoading is set to requiredComponents, a custom component, if configured with a placeholder component, is automatically considered as a lazy-loaded component, regardless of whether the component is in the main package or a subpackage (same as asynchronous package splitting).