UI5 性能参数:data-sap-ui-preload 与 data-sap-ui-async

UI5 performance parameters: data-sap-ui-preload vs. data-sap-ui-async

不同的 SAPUI5 性能指南提到了两个关键参数,它们似乎具有相似的性质,但解释略有不同:

  1. data-sap-ui-preload="async"

The most important setting here is data-sap-ui-preload="async". This enables the runtime to load the modules for all declared libraries asynchronously in the background. This reduces the amount of requests sent by the client that could block each other.

  1. data-sap-ui-async="true"

The most important setting is data-sap-ui-async="true". This enables the runtime to load all the modules and preload files for all declared libraries asynchronously, if an asynchronous API is used. Setting async=true leverages the browser's capabilities to execute multiple requests in parallel, without blocking the UI thread.

能否请您说明一下究竟有什么区别,我什么时候应该使用一个而不是另一个?

第一个链接文档基于过时的 UI5 版本 1.38.x。那个时候配置 sap-ui-preload="async" 确实是“最重要的设置”,因为当时没有 sap-ui-async 可用。在版本 1.58.2 中,引入了 async="true",应该使用它来代替主题 Configuration Options and URL Parameters:[= 中所述的 preload="true" 26=]

preload

This configuration parameter defines the loading behaviour of the so-called preload files. […] The values are used as follows:

  • […]
  • When set to async, the preload files are loaded asynchronously. However, we recommend to use the async=true configuration parameter in the bootstrap instead, because it switches more module/related APIs to async including the loading behaviour of the preload files.

async

This configuration setting enables the module loader to load both, modules and library-preload files asynchronously.


TL;DR

data-sap-ui-async="true" // since 1.58.2 --> Replaces preload="async" *
data-sap-ui-preload="async" // for 1.58.1 and below

* 先决条件:Is Your Application Ready for Asynchronous Loading?

我想向 of Boghyon. It's not a replacement in regards to data-sap-ui-async and data-sap-ui-preload. data-sap-ui-async is an additional offering which enables simply more asynchronous features of UI5. See also the performance section 添加更多信息。