1. 首页
  2. IT教程

SAP UI5加载时的library-preload.json文件

library-preload.json文件的作用,在Jerry的博客How I do self-study on a given Fiori control – part 1里有介绍:

In productive use, for performance reasons, all controls of a library are also available in the library-preload.json file, which is loaded initially (and can be loaded asynchronously). It contains each control/module as a string, which is then parsed into JavaScript on demand. So this avoids many HTTP requests and thus improves performance.

以上文字来自SAP UI5开发人员:Kunz Andreas:

SAP UI5加载时的library-preload.json文件

我试着简单翻译一下:

在productive使用场景下,处于性能考虑,一个SAP UI5应用的单个library里包含的所有控件实现会被打包成单个的文件library-preload.json中去,可以在SAP UI5应用bootstrap阶段加载或者按需进行异步加载。Library-preload.json以字符串的格式包含了每个control/module的实现,可以被解析成JavaScript对象在SAP UI5框架里使用。这种打包成单个库文件然后加载的方式,减少了HTTP请求的数量,提高了性能。

SAP UI5加载时的library-preload.json文件

上图是按照Jerry文章一个用于SAP UI5学习的脚手架应用,没有任何后台API的依赖里介绍的方法,开发了一个只包含button控件的最简单的SAP UI5应用,加载之后在Chrome开发者工具里观察到的网络请求,其中包含四个library-preload.js的加载:

  • https://openui5.hana.ondemand.com/resources/sap/ui/core/library-preload.js
  • https://openui5.hana.ondemand.com/resources/sap/ui/commons/library-preload.js
  • https://openui5.hana.ondemand.com/resources/sap/ui/layout/library-preload.js
  • https://openui5.hana.ondemand.com/resources/sap/ui/unified/library-preload.js

更多Jerry的原创文章,尽在:“汪子熙”:

原创文章,作者:夜风博客,如若转载,请注明出处:https://www.homedt.net/450352.html