preload(preloadDump)

Preload all content encoded inside the provided preload dump.

Copy
await Scrivito.preload(thePreloadDump);
ReactDOM.render(<App />, document.getElementById('application'));

A preload dump is generated when pre-rendering a page using Scrivito.renderPage. Preloading the dump allows you to load all the required content into the browser before mounting your React application. This will eliminate any intermediate loading states that could lead to flickering as the pre-rendered HTML is replaced by the React application.

Returns

A Promise. The Promise resolves with an object once preloading has finished. The promise result object contains the dumpLoaded key with a boolean value that indicates whether the dump was actually loaded. In order to benefit from preloading, you should wait for this before mounting the application.

Note that preloading is intended as a performance optimization. It is a best-effort approach, i.e., if anything goes wrong during preloading, Scrivito will still resolve the Promise.

Remarks

The dump is not used if:

  • the application serves content in the UI: Scrivito.isEditorLoggedIn(), or
  • visitor authentication has been enabled: Scrivito.configure({ visitorAuthentication: true }). This is because the dump data contains only public content.