Loading Web components
Last updated
Was this helpful?
Last updated
Was this helpful?
Since is an open-source package, it is available through different channels:
From the registry
From the CDN
This gives us two ways to load the web components artifact for use in recommendation templates:
Using the client script, configured through Nosto's Admin UI under Product Experience Cloud > Recommendations > Settings (recommended)
Using module scripts in every recommendation template (see )
The following sections detail each approach along with its advantages and disadvantages.
A new toggle has been introduced on the Recommendation Settings page to control the loading of the web components artifact. Enabling this option requires specifying the version of the artifact to load when recommendations are rendered on store pages.
For a list of all available versions, refer to the link provided on the settings page.
Controlled directly by Nosto and loaded automatically via the client script, eliminating the need to include the artifact in every recommendation template.
Updating the version is straightforward since the version is controlled via settings rather than having to change it in every recommendation template.
Version control is global; updating the version in settings applies it to all recommendation templates, so it cannot be set individually for each page.
The web components artifact is loaded on all pages, even when a particular page does not utilize web components.
If you prefer not to enable web components globally via the recommendation settings, you can include the web components artifact directly within individual recommendation templates.
Since the web components artifact is an ES module, include it using a script tag as shown below:
The version of the web components artifact can be chosen individually for each template. This is beneficial when a particular version does not work in a template, and a fix for the issue is released in a newer version. Please note that the web components version is page-scoped (for example, front, product, cart, etc.), meaning only one version can be loaded per page.
The web components artifact is loaded only when it is used in a recommendation template.
The script tag must be included in each recommendation template individually.
Maintaining and upgrading the version in every recommendation template can be a tedious process.