What are the effects if I put less/more in data-sap-ui-libs
? How do they differ?
My recommendation is to remove data-sap-ui-libs
from index.html
altogether. Especially if the app is dealing with OData, it's important to retrieve the $metadata
document as early as possible. See the example below:
In index.html
<head>
<script id="sap-ui-bootstrap"
src="https://ui5.sap.com/<version>/resources/sap-ui-core.js"
data-sap-ui-theme="sap_horizon"
data-sap-ui-oninit="module:sap/ui/core/ComponentSupport"
data-sap-ui-async="true"
data-sap-ui-compatversion="edge"
data-sap-ui-excludejquerycompat="true"
data-sap-ui-resourceroots='{ "demo": "./" }'
data-sap-ui-xx-waitfortheme="init"
></script><!-- No data-sap-ui-lib -->
</head>
<body id="content" class="sapUiBody">
<div style="height: 100%"
data-sap-ui-component
data-name="demo"
data-height="100%"
></div>
</body>
In manifest.json
{
"sap.app": {
"dataSources": {
"myODataSource": {
"uri": "/odata_org/V2/Northwind/Northwind.svc/",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "model/metadata.xml",
"annotations": [
"annotation0"
]
}
},
"annotation0": {
"type": "ODataAnnotation",
"uri": "annotation/annotation0.xml",
"settings": {
"localUri": "annotation/annotation0.xml"
}
}
},
"...": "..."
},
"sap.ui5": {
"dependencies": {
"minUI5Version": "1.108.4",
"libs": {
"sap.ui.core": {},
"sap.m": {},
"sap.ui.table": {},
"sap.ui.unified": {}
}
},
"models": {
"": {
"dataSource": "myODataSource",
"settings": {
"preliminaryContext": true,
"tokenHandling": false
},
"preload": true
}
},
"...": "..."
},
"...": "..."
}
Result

As you can see, the $metadata
document is being fetched in parallel with the control libraries. This ensures that entities can be requested right away (e.g. in $batch
) as soon as the libs are loaded. If libs were declared in data-sap-ui-libs
, they'd be loading first, then the $metadata
, and then the entities which creates an unnecessary bottleneck.
But even without considering OData, I noticed the page gets already a bit faster when the libs are removed from data-sap-ui-libs
. In general, try different approaches and do performance measurements, in addition to documented performance guidelines, and regardless of what people say (including me).
TL;DR
- Use
data-sap-ui-libs
only if:
- The app has no
Component.js
at all.
- Modules from libraries other than
sap.ui.core
are accessed before creating the component (E.g. instantiating sap.m.Shell
as a shell for the ComponentContainer
)
- Otherwise, remove
data-sap-ui-libs
altogether and maintain /sap.ui5/dependencies/libs
only - Especially if the app is supposed to be launched from an app container such as SAP Fiori launchpad (FLP) which skips loading index.html
altogether.
See also What happens if a library preload file / library dependencies is not updated in the UI5-manifest?