In the OpenUI5 documentation is written:
Now, we create a new
index.js
script that will contain the application logic for this tutorial step. We do this to avoid having executable code directly in the HTML file for security reasons. This script will be called by theindex.html
. We defined it there as a module in a declarative way.
In other words, the official OpenUI5 documentation advices to extract the following code:
<script>
"use strict";
sap.ui.getCore().attachInit(function () {
new sap.m.Shell("", {
appWidthLimited: false,
app: new sap.ui.core.ComponentContainer("", {
name: "webapp",
height: "100%"
})
}).placeAt("content");
});
</script>
into a separate JS-file:
"use strict";
sap.ui.getCore().attachInit(() => {
new sap.m.Shell("", {
app: new sap.ui.core.ComponentContainer("", {
height: "100%",
name: "webapp"
}),
appWidthLimited: false
}).placeAt("content");
});
I'm curious to know how exactly extracting the JS-code from the HTML-page into a separate JS-file can contribute to the UI5 application security?