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

UI5 performance parameters: data-sap-ui-async vs. data-sap-ui-xx-nosync

UI5 bootstrapper 有两个参数,负责 UI5 加载库的方式:

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.

我知道 data-sap-ui-xx-nosync="warn" 允许识别同步加载的库。

但是使用data-sap-ui-xx-nosync="true"有什么好处呢?

Configuration Options and URL Parameters 中所述,data-sap-ui-xx-nosync="true" 生成 new Error 而不是简单的日志。

When set to warn, any use of synchronous XHRs will be reported with a warning in the console. When set to true, such calls will cause an error.

例如 Error depends on the caller and the application code. In some cases, such errors can break the app. See this plunk 会发生什么。使用true,无法加载自定义JS文件。

What are the benefits of using data-sap-ui-xx-nosync="true"?

由于 true 抛出一个实际的错误实例,您可能希望对此类事件做出反应,例如window.addEventListener("error", fn)。可能对回归测试有用。