问题
In SAPUI5 when you add a sap.m.DatePicker
to your app for the first time it takes some seconds to load the required files and open the date picker. In the API they explained:
Note: The sap.ui.unified.Calendar is used internally only if the DatePicker is opened (not used for the initial rendering). If the sap.ui.unified library is not loaded before the DatePicker is opened, it will be loaded upon opening. This could lead to a waiting time when the DatePicker is opened for the first time. To prevent this, apps using the DatePicker should also load the sap.ui.unified library.
So this it the solution they suggest for making the loading of DatePicker faster.
When I use sap.ui.comp.smarttable.SmartTable
it takes at least 10 to 15 seconds for the first time that user can see the app.
Actually it loads a huge number of individuals JavaScript files. Here is a small part of the files that are loaded.
Now the question is, Is there anyway to make this loading faster?
I tried the following code in the dependencies
of manifest but was not helpful.
"sap.ui.comp": {
"minVersion": "1.52.1"
}
回答1:
SmartTable is a huge control that has dependencies to the following libraries:
"sap.ui.core"
"sap.m"
"sap.ui.comp"
"sap.ui.table"
which, again, depends on .."sap.ui.unified"
This can be seen in the source code of the module:
sap.ui.comp.smarttable.SmartTable
sap.ui.define([ 'jquery.sap.global', 'sap/m/VBoxRenderer', 'sap/m/Column', // ... 'sap/ui/comp/library', 'sap/ui/comp/providers/TableProvider', 'sap/ui/comp/smartfilterbar/FilterProvider', 'sap/ui/comp/smartvariants/SmartVariantManagement', // ... 'sap/ui/table/AnalyticalColumn', 'sap/ui/table/AnalyticalTable', 'sap/ui/table/Column', 'sap/ui/table/Table', 'sap/ui/table/TreeTable', // ... ], function(/*...*/) {/*...*/});
Try to preload those libraries beforehand asynchronously, for example,
With this bootstrap config:
// since 1.58.2 data-sap-ui-async="true" // replaces -preload="async" and -xx-async="true"
And in the app descriptor if the app is component-based:
"sap.ui5": { "dependencies": { "libs": { "sap.ui.core": {}, "sap.m": {}, "sap.ui.comp": {}, "sap.ui.table": {}, "sap.ui.unified": {} }, ... }, ... }
This should load the table faster since its dependencies don't need to be loaded on-demand and synchronously anymore which avoids freezing the UI thread of the browser.
Notes
As of v1.52 src,
preload="async"
(nowasync="true"
) also includes preloadingmessagebundle*.properties
files which was not the case until then.For other performance related best-practices, see the documentation topic Performance: Speed Up Your App.
来源:https://stackoverflow.com/questions/49817459/how-to-load-sap-ui-comp-smarttable-smarttable-faster