Using the Loading Optimization Setting on a Story Level

Objective

After completing this lesson, you will be able to select the correct loading optimization setting that will work best for story design.

Loading Optimization Settings

Technically, the instance of a data-bound widget is created first. As soon as the instance is available, then the widget is accessible by scripting and pending for rendering.

If, and when, a data-bound widget is rendered depends on the story's Loading Optimization Setting:

  • Viewport Loading
  • Background Loading
  • None
SAP Analytics Cloud story with the Data Refresh menu open showing the three Loading Optimization Settings (highlighted).

Viewport Loading

For Viewport Loading, the rendering phase is split up into three different sub-phases:

  1. Initial rendering phase
  2. Background rendering phase
  3. Viewport rendering phase

Background Loading

For Background Loading, the rendering phase is split up into two different sub-phases:

  • Initial rendering phase
  • One or two background rendering phases (depending on scripts processing)

None

For None, there is only an initial rendering phase.

Introducing the Data Loading Story

In this lesson, the same story is used in all scenarios to demonstrate the different Loading Optimization Settings available to you. Let's take a closer look at the story, as it's important to know how the story is built, in order to understand the data loading flow as we explore the data loading scenarios.

Summary

In general, the following statements are true:

  • All content in the visible area of the story is fully rendered as soon as the initial rendering phase is complete.
  • The user can start to interact with the story to trigger scripting (for example, press a button that runs a script) as soon as the initial rendering AND the script execution of the page.onInitialization and page.onActive event scripts are processed.
  • Any widget that is referenced in a script is rendered, regardless of if it is part of the visible area or not.

Loading Optimization Setting: Viewport Loading

Viewport Loading is the default setting for all stories.

Using this setting means that from the data-bound widgets in the story, only those within the visible area of the story (viewport) are rendered. As the user navigates in the page, then the data-bound widgets that become part of the new viewport are rendered. This means that if the user does not look at the whole story, then the unneeded data-bound widgets may never be rendered.

In this lesson, we will explore the flow for two scenarios:

  1. onInitialization and onActive events finish before the initial rendering phase.
  2. onInitialization and onActive events finish after the initial rendering phase.

Data Flow: Loading Optimization Setting Viewport Loading

In the examples below, you can see the key steps in the rendering process, numbered 1-4:

  1. Loading screen appears.
  2. onInitialization script complete.
  3. Initial viewport rendering complete.
  4. User can interact with story content to trigger scripting.

Scenario 1: Script Execution Finishes Before the Initial Rendering Phase:

Diagram showing viewpoint loading when onInitialization and onActive events finish before initial rendering. Steps 1-4 shown, as described above the diagram.

Scenario 2: Script Execution Finishes After the Initial Rendering Phase:

Diagram showing viewpoint loading when onInitialization and onActive events finish after initial rendering. Steps 1-4 shown, as described above the diagram.

Initial Rendering Phase

In the initial rendering (R1) phase, the following data-bound widgets are rendered:

  • Viewable data-bound widgets.
  • Data-bound widgets that do not support background loading or viewport loading.
  • Data-bound widgets that are flagged with Always initialize on startup.
  • Data-bound widgets that are referenced in the current page's onInitialization or onActive events.

Script Execution

In parallel to the initial rendering phase, the script of the script (S1)- onInitialization event of the current page is processed. When it is finished, the script of the script (S2) - onActive event of the current page is processed.

Note

If a script call in either the onInitialization or onActive event references a data-bound widget that has not yet completely rendered, then the call will pause and wait for the widget to be rendered before the script call is executed.

Background Rendering Phase

After the scripts have been processed, in the background rendering (R2) phase, data-bound widgets that are referenced by any script or script function are rendered.

As you can see in scenarios 1 and 2, this rendering process can start either during or after the initial rendering phase, depending on the duration of the script execution.

Viewport Rendering Phase

In the viewport rendering (R3) phase, when a user navigates to a new area of a story that was not previously viewed, then any corresponding data-bound widgets that were not previously rendered will be rendered at this point.

Using the Viewport Loading Optimization Setting

In this video, we will explore the Loading Optimization Setting: Viewport Loading, how it affects the data loading of your story, and scenarios for using the setting in your story.

Widget Rendering Overview for Loading Optimization Setting: Viewport Loading

The following table summarizes the data-bound widget rendering when Viewport Loading is selected:

ViewableReferenced by the page onInitialization/onActive event scriptReferenced by other scriptsAlways initialize on startupWidget rendered in rendering phase
TRUEN/AN/AN/AINITIALIZATION
FALSETRUEN/AN/AINITIALIZATION
FALSEFALSEN/ATRUEINITIALIZATION
FALSEFALSETRUEFALSEBACKGROUND
FALSEFALSEFALSEFALSEVIEWPORT

Widgets are not rendered by default, only when they become viewable.

Loading Optimization Setting: Background Loading

Using the Background Loading setting means that widgets within the viewport are rendered first and all other data-bound widgets on the current page are rendered afterward, regardless of if the user ever looks at them or not. This might result in unnecessary rendering and data loading requests.

In this lesson, we will explore the flow for two scenarios:

  1. Script execution finishes before initial rendering phase.
  2. Script execution finishes after initial rendering phase.

Data Flow: Loading Optimization Setting Background Loading

In the examples below, you can see the key steps in the rendering process, numbered 1-4:

  1. Loading screen appears.
  2. onInitialization script complete.
  3. Initial viewport rendering complete.
  4. User can interact with story content to trigger scripting.

Scenario 1: Script Execution Finishes Before the Initial Rendering Phase:

Diagram showing background loading when script execution finish before initial rendering. Steps 1-4 shown, as described above the diagram.

Scenario 2: Script Execution Finishes After the Initial Rendering Phase:

Diagram showing background loading when script execution finish after initial rendering. Steps 1-4 shown, as described above the diagram.

Initial Rendering Phase

In the initial rendering (R1) phase, the following widgets are rendered:

  • Viewable data-bound widgets.
  • Data-bound widgets that do not support background loading.
  • Data-bound widgets that are flagged with Always initialize on startup.
  • Data-bound widgets that are referenced in the current page's onInitialization or onActive event.

    Note

    • Widgets retrieved by Application.getWidgets() script API are not recognized as referenced by script.
    • Using Application.getWidgets() API to search widget by table type will force rendering of all tables.

Script Execution

In parallel to the initial rendering phase, the script of the script (S1) - onInitialization event of the current page is processed. When it is finished, the script of the script (S2) - onActive event of the current page is processed.

Note

If a script call in either the onInitialization or onActive event references a data-bound widget that has not yet completely rendered, then the call will pause and wait for the widget to be rendered before the script call is executed.

Background Rendering Phase(s)

In the first scenario, where the script execution finishes before the initial rendering phase, there are two background rendering phases. During background rendering (R2) any data-bound widget referenced in the onInitialization and onActive event scripts are rendered. In the background rendering (R3) phase, all other data-bound widgets on the current page that are not yet rendered start their rendering.

In the second scenario, where the script execution finishes after the initial rendering phase, in the background rendering (R2) phase, all other data-bound widgets on the current page that are not yet rendered start their rendering.

Using the Background Loading Optimization Setting

In this video, we will explore the Loading Optimization Setting: Background Loading, how it affects the data loading of your story, and scenarios for using the setting in your story.

Widget Rendering Overview for Loading Optimization Setting: Background Loading

The following table summarizes the data-bound widget rendering when Background Loading is selected:

ViewableReferenced by the page onInitialization/onActive event scriptReferenced by other scriptsAlways initialize on startupWidget rendered in rendering phase
TRUEN/AN/AN/AINITIALIZATION
FALSETRUEN/AN/AINITIALIZATION
FALSEFALSEN/ATRUEINITIALIZATION
FALSEFALSETRUEFALSEBACKGROUND
FALSEFALSEFALSEFALSEBACKGROUND

Loading Optimization Setting: None

Using this setting means that all data-bound widgets in the story are rendered at startup. After that, the onInitialization and onActive event scripts are processed.

This setup can be used to ensure that all widgets are rendered so that the user never has to wait for any additional rendering while navigating within the story.

Data Flow: Loading Optimization Setting None

In the example below, you can see the key steps in the rendering process, numbered 1-4.

  1. Loading screen appears.
  2. onInitialization script complete.
  3. Initial viewport rendering complete.
  4. User can interact with story content to trigger scripting.
Diagram showing Loading Optimization Setting: None. Steps 1-4 shown, as described above the diagram.

Initial Rendering Phase

In the initial rendering (R1) phase, all data bound widgets are rendered.

Script Execution

After the initial rendering phase, script (S1) in the onInitialization event of the current page is processed. When it is finished, script (S2) in the onActive event of the current page is processed.

Using the None Loading Optimization Setting

In this video, we will explore the Loading Optimization Setting: None, how it affects the data loading of your story, and scenarios for using the setting in your story.

Widget Rendering Overview for Loading Optimization Setting: None

The following table summarizes the data-bound widget rendering when None is selected:

ViewableReferenced by the page onInitialization/onActive event scriptReferenced by other scriptsAlways initialize on startupWidget rendered in rendering phase
N/AN/AN/AN/AINITIALIZATION

Timepoint for User Interaction Using Scripting

Next, let's look at the settings' impact on users and their ability to interact with a story using scripting.

We will explore the Viewport Loading and Background Loading when the onActive script finishes before and after the initial rendering phase, as well as the data loading scenario for the None setting.

Summary

The Loading Optimization Setting that you select, and the duration of the scripts in your story, will impact on when the users can interact with the story to trigger scripting.

Knowing how they use the story and including visual hints that there is still processing happening in the background will improve user experience in the story and is something to consider when understanding the requirements and planning the story design.

Log in to track your progress & complete quizzes