// App.jsx
import {
prefetch,
PrefetchFeatures
}
from '@thoughtspot/visual-embed-sdk';
...
prefetch
({
url: "https://<hostname>:<port>",
prefetchFeatures: [PrefetchFeatures.LiveboardEmbed,PrefetchFeatures.VizEmbed]
});
...
// post-login.jsx
// might need to be called after login to get
// the user's context.
import {
AuthType,
init,
}
from '@thoughtspot/visual-embed-sdk';
init
({
thoughtSpotHost: "https://<hostname>:<port>",
authType: AuthType.None,
});
Prefetch static resources
By default, the SDK fetches application resources when the embedded app content is requested. For optimal performance and faster loading of embedded objects, we recommend prefetching static resources and serving these static assets from the local cache of the user’s browser.
To prefetch static resources, use one of these options:
-
Use the
prefetch
method (Recommended)The
prefetch
method in the SDK allows your web browsers to prefetch static resources from a given URL on application load. In theprefetch
method, you can define the prefetch URL and specify the embed components for which you want to prefetch resources. To improve application response time, ThoughtSpot recommends that you call theprefetch
method as soon as possible when your application initializes.In the following example, the
prefetch
method is called beforeinit
to prefetch resources before the authentication process is initialized. -
Call prefetch in
init
You can call prefetch in the
init
method by setting thecallPrefetch
attribute totrue
.import { LiveboardEmbed, AuthType, init, prefetch, } from '@thoughtspot/visual-embed-sdk'; init ({ thoughtSpotHost: "https://<hostname>:<port>", authType: AuthType.None, callPrefetch: true });