docs

Step 2: Bootstrap

Before we can do something with OpenUI5, we need to load and initialize it. This process of loading and initializing OpenUI5 is called bootstrapping. Once this bootstrapping is finished, we simply display an alert.


Preview

An alert "UI5 is ready" is displayed


Coding

You can view and download all files at Walkthrough - Step 2.


UI5 Tooling

First, let’s enhance your UI5 Tooling setup:

  1. Open a terminal from the app root folder.

  2. Execute ui5 use OpenUI5
  3. Execute ui5 add sap.ui.core sap.m themelib_sap_horizon

webapp/index.html

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>UI5 Walkthrough</title>
	<script
		id="sap-ui-bootstrap"
		src="resources/sap-ui-core.js"
		data-sap-ui-theme="sap_horizon"
		data-sap-ui-libs="sap.m"
		data-sap-ui-compat-version="edge"
		data-sap-ui-async="true"
		data-sap-ui-on-init="module:ui5/walkthrough/index"
		data-sap-ui-resource-roots='{
			"ui5.walkthrough": "./"
		}'>

	</script>
</head>
<body>
<div>Hello World</div>
</body>
</html>

In this step, we load the OpenUI5 framework from the webserver provided by UI5 Tooling and initialize the core modules with the following configuration options:


webapp/index.js (New)

sap.ui.define([], () => {
	"use strict";
	alert("UI5 is ready");
});

Now, we create a new index.js script that contains 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 from index.html. We defined it there as a module in a declarative way.

In the next steps, the structure of a UI5 module will be explained in detail.

Parent topic:Walkthrough Tutorial (JavaScript)

Next:Step 1: Hello World!

Previous:Step 3: Controls

Related Information

Compatibility Version Information

Bootstrapping: Loading and Initializing

Standard Variant for Bootstrapping

Content Security Policy