Skip to content

Commit e39c26e

Browse files
committed
10.10.0.cl-preRender : minor updates
1 parent f6b43af commit e39c26e

16 files changed

+74
-73
lines changed

modules/ROOT/pages/prerender.adoc

Lines changed: 74 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,57 @@
1010

1111
The following diagrams illustrate how ThoughtSpot embed components load in a typical application, both for normal and pre-rendered scenarios. Reviewing these will help set the context for the strategies described in this guide.
1212

13-
image::./images/pre-render/embed_load.png[]
14-
image::./images/pre-render/liveboardEmbed_load.png[]
13+
=== Basic Embed Load Flow
1514

16-
== How Embedding Normally Works (The Basics)
15+
When a ThoughtSpot embed loads, it goes through several distinct phases:
16+
17+
image::./images/pre-render/dig1.1.png[]
18+
19+
In the diagram above, each block represents a step in the embed loading process, and each block takes time to complete. The ThoughtSpot embed loading process consists of:
20+
21+
1. **Host App Load** - Your application initializes and loads
22+
2. **Init** - ThoughtSpot SDK initialization and login.
23+
3. **ThoughtSpot Embed Loads** - The load time taken for the embed to load.
24+
25+
image::./images/pre-render/dig1.2.png[]
26+
27+
As shown in the detailed diagram above, each block represents a distinct step that takes time to execute. The ThoughtSpot embed load process can be further broken down into the following phases:
28+
29+
* **Common Asset Load** – Loading shared JavaScript and CSS files
30+
* **Common Bootstrap** – Setting up the basic embed framework
31+
* **Embed Level Asset Load** – Loading specific assets for the embed type
32+
* **Embed API Calls** – Fetching data and rendering the content
1733

18-
When you embed ThoughtSpot (or any analytics app) in your application, the typical flow is:
34+
=== Optimized Load Flow with Early Init
35+
36+
For applications that have a loading screen or home page before the liveboard embed, you can optimize performance by calling init in parallel:
37+
38+
image::./images/pre-render/dig2.png[]
39+
40+
This diagram shows how you can start the authentication/login process early by calling init while the end user is still on the home page or loading screen. Note that this only handles the login process in parallel - no assets are loaded during this phase.
41+
42+
== How Embedding Normally Works (The Basics)
1943

20-
. The user navigates to a page with the embed component.
21-
. The embed component is rendered in the DOM.
22-
. The browser loads the ThoughtSpot iframe and all required assets (JS, CSS, etc).
23-
. The iframe initializes, fetches data, and finally displays the analytics.
44+
When you embed ThoughtSpot in your application, the typical flow is:
2445

25-
This means *every time* a user visits the page, the iframe and all assets are loaded from scratch, causing a visible delay before analytics appear.
46+
. Call init (authentication/SDK initialization)
47+
. Render the embed component
48+
. Embed loads the iframe
49+
. Iframe loads assets, calls APIs, and shows the analytics
2650

27-
image::./images/pre-render/embed_load.png[]
51+
This means *every time* an end user visits the page, the iframe and all assets are loaded from scratch, causing a visible delay before analytics appear.
2852

2953
== What is Pre-rendering?
3054

31-
Pre-rendering changes this flow by *loading some or all of the assets and initialization steps in the background*, before the user actually navigates to the analytics. This way, when the user visits the page, the analytics are ready to show instantly (or much faster).
55+
Pre-rendering changes this flow by *loading some or all of the assets and initialization steps in the background*, before the end user actually navigates to the analytics. This way, when the end user visits the page, the analytics are ready to show instantly (or much faster).
56+
57+
You can preload just the common assets, or even a specific liveboard, depending on your needs. This doc explains the different pre-render strategies, when to use each, and how to implement them in React or JavaScript.
3258

3359
[NOTE]
3460
====
35-
Pre-rendering is most effective when your application has a loading page, landing page, or pre-embed page where you can start the pre-render process before the user navigates to the analytics. If a user navigates directly to the embed page (for example, via a direct link or bookmark), pre-rendering cannot provide a speed benefit because there is no opportunity to load assets in advance.
61+
Pre-rendering is most effective when your application has a loading page, landing page, or pre-embed page where you can start the pre-render process before the end user navigates to the analytics. If an end user navigates directly to the embed page (for example, via a direct link or bookmark), pre-rendering cannot provide a speed benefit because there is no opportunity to load assets in advance.
3662
====
3763

38-
Pre-rendering can preload just the common assets, or even a specific liveboard, depending on your needs. The rest of this doc explains the different strategies and how to use them.
39-
40-
Pre-rendering lets you load ThoughtSpot embed components in the background, so users see analytics instantly when they navigate to them. This doc explains the different pre-render strategies, when to use each, and how to implement them in React or JavaScript.
41-
4264
== Why Pre-render?
4365

4466
* Reduce wait times for embedded analytics
@@ -51,9 +73,11 @@ Pre-rendering lets you load ThoughtSpot embed components in the background, so u
5173

5274
- Fully loads the embed iframe, including all assets and liveboard data, as soon as the component is rendered.
5375
- Fastest experience for a specific liveboard.
54-
- Maximum resource usage if the user never views the embed.
76+
- Maximum resource usage if the end user never views the embed.
5577

56-
To use this strategy, place the following component on your application's home page, loading page, or landing page (before the user navigates to the analytics):
78+
image::./images/pre-render/dig3_pre_with_livid.png[]
79+
80+
To use this strategy, place the following component on your application's home page, loading page, or landing page (before the end user navigates to the analytics):
5781

5882
[source,jsx]
5983
----
@@ -70,30 +94,26 @@ The value of `preRenderId` can be any string, but it must match the `preRenderId
7094
Limitation: Any props you want to pass to the embed (such as configuration options) must be passed to the `PreRenderedLiveboardEmbed` component on the home page. If you later render a `LiveboardEmbed` with the same `preRenderId`, those new props will not be respected if the iframe is already loaded. This is a current limitation of the pre-rendering approach.
7195
====
7296

73-
[example]
97+
When you actually want to show the liveboard, call this component:
98+
99+
[source,jsx]
74100
----
75-
// React example
76-
import { LiveboardEmbed } from "@thoughtspot/visual-embed-sdk/react";
77-
78-
const PreRenderLiveboardWithLiveboardId = () => (
79-
<LiveboardEmbed
80-
preRenderId="pre-render-with-liveboard-id"
81-
liveboardId="e40c0727-01e6-49db-bb2f-5aa19661477b"
82-
className="embed-div"
83-
/>
84-
);
101+
<LiveboardEmbed
102+
preRenderId="pre-render-with-liveboard-id"
103+
liveboardId="e40c0727-01e6-49db-bb2f-5aa19661477b"
104+
/>
85105
----
86106

87-
image::./images/pre-render/pre_render_with_liveboard_id.png[]
88-
89107
=== 2. Prerender without Liveboard ID
90108

91109
- Loads common assets and bootstrap logic early.
92110
- Defers liveboard-specific data/API calls until needed.
93111
- Keeps the app ready, making the first liveboard load faster.
94-
- Still loads some assets even if the user never opens the embed.
112+
- Still loads some assets even if the end user never opens the embed.
95113

96-
To use this strategy, place the following component on your application's home page, loading page, or landing page:
114+
image::./images/pre-render/dig4_wo_livid.png[]
115+
116+
To use this strategy, place the following component on your application's home page, loading page, or landing page (before the end user navigates to the analytics):
97117

98118
[source,jsx]
99119
----
@@ -102,82 +122,65 @@ To use this strategy, place the following component on your application's home p
102122
/>
103123
----
104124

105-
Again, the value of `preRenderId` can be any string, but it must match the `preRenderId` you use when rendering the actual embed later.
125+
The value of `preRenderId` can be any string, but it must match the `preRenderId` you use when rendering the actual embed later.
106126

107127
[NOTE]
108128
====
109129
Limitation: Any props you want to pass to the embed must be passed to the `PreRenderedLiveboardEmbed` component on the home page. If you later render a `LiveboardEmbed` with the same `preRenderId`, those new props will not be respected if the iframe is already loaded.
110130
====
111131

112-
[example]
132+
When you actually want to show the liveboard, call this component:
133+
134+
[source,jsx]
113135
----
114-
// React example
115-
import { LiveboardEmbed } from "@thoughtspot/visual-embed-sdk/react";
116-
117-
const PreRenderLiveboardWithoutLiveboardId = () => (
118-
<LiveboardEmbed
119-
preRenderId="pre-render-without-liveboard-id"
120-
liveboardId="e40c0727-01e6-49db-bb2f-5aa19661477b"
121-
className="embed-div"
122-
/>
123-
);
136+
<LiveboardEmbed
137+
preRenderId="pre-render-without-liveboard-id"
138+
liveboardId="e40c0727-01e6-49db-bb2f-5aa19661477b"
139+
/>
124140
----
125141

126-
image::./images/pre-render/prerender_without_liveboard_id.png[]
127-
128142
=== 3. Prerender On Demand
129143

130-
- Loads nothing up front; the embed is loaded only when the user navigates to it.
144+
- Loads nothing up front; the embed is loaded only when the end user navigates to it.
131145
- On first visit, the embed loads normally; on return, the iframe is reused and appears instantly.
132146
- Most efficient; only loads if needed, and reuses the iframe for instant reloads.
133147

148+
image::./images/pre-render/dig5_ondemand.png[]
149+
134150
When you render a component with a `preRenderId` for the first time, it loads as usual. The next time you render a component with the same `preRenderId`, the load is instant because the iframe is reused.
135151

136152
This strategy does not require special configuration—simply pass a `preRenderId` prop to your normal component render:
137153

138154
[source,jsx]
139155
----
140-
<LiveboardEmbed preRenderId="pre-render-on-demand" className="embed-div" />
156+
<LiveboardEmbed preRenderId="pre-render-on-demand" />
141157
----
142158

143-
[example]
144-
----
145-
// React example
146-
import { LiveboardEmbed } from "@thoughtspot/visual-embed-sdk/react";
147-
148-
const PreRenderEmbedOnDemand = () => (
149-
<LiveboardEmbed preRenderId="pre-render-on-demand" className="embed-div" />
150-
);
151-
----
152-
153-
image::./images/pre-render/preRender_on_demand.png[]
154-
155159
=== 4. Normal Render
156160

157161
- Default behavior; loads the embed only when the component is rendered.
158162
- On every visit, the iframe is recreated and the embed loads from scratch.
159-
- Efficient if the embed is rarely used, but slow for the user every time.
163+
- Efficient if the embed is rarely used, but slow for the end user every time.
164+
165+
image::./images/pre-render/dig2.png[]
160166

161167
[example]
162168
----
163-
// React example
164-
import { AppEmbed } from "@thoughtspot/visual-embed-sdk/react";
165-
166-
const NormalEmbed = () => <AppEmbed className="embed-div" />;
169+
<LiveboardEmbed liveboardId="some-liveboard-id" />
167170
----
168171

169-
image::./images/pre-render/normal_embed_load.png[]
170-
171-
=== 5. Prefetch
172+
=== 5. Prefetch Assets
172173

173174
- Loads a few common JS/CSS assets in parallel with your app.
174175
- No liveboard data or API calls are made.
175176
- Minimal benefit (modern browsers cache these assets anyway).
176-
- Wastes bandwidth if the user never opens the embed.
177+
- Wastes bandwidth if the end user never opens the embed.
178+
179+
image::./images/pre-render/dig6_prefetch.png[]
177180

178181
[NOTE]
179182
====
180-
Prefetch is generally not recommended unless you have a specific need, as modern browsers already cache static assets efficiently. Using prefetch may result in unnecessary network usage without significant performance gain.
183+
As modern browsers already cache static assets efficiently, using prefetch may not provide a significant performance gain.
181184
====
182185

183186
.Example: Prefetching assets
@@ -199,8 +202,6 @@ init({
199202
});
200203
----
201204

202-
image::./images/pre-render/preFetch.png[]
203-
204205
== Strategy Comparison Table
205206

206207
[cols="1,1,1,1,1,1,2",options="header"]
78 KB
Loading
108 KB
Loading
156 KB
Loading
237 KB
Loading
293 KB
Loading
316 KB
Loading
338 KB
Loading
177 KB
Loading
-131 KB
Binary file not shown.

0 commit comments

Comments
 (0)