Frontend
Theme JS

Cumulative Layout Shift Facade/Placeholder

4min

Suggestions on how to best handle CLS can be found in our knowledge base.

SRLP and Category Navigation

When Klevu Theme JS is used for Search Results Landing Page and/or Category Navigation the content is loaded from Klevu after the page has loaded. This can cause layout shifts and affect your page speed insights scores.

To mitigate this layout shift we have added CSS to create an area where this content will be loaded. This works out of the box with the default theme, however, it will likely require changes if you customise the theme.

CSS


This is injected into the phtml files for both SRLP and Category Navigation via a container.

module-m2-frontend-search/view/frontend/templates/search/results.phtml module-m2-frontend-categorynavigation/view/frontend/templates/category.phtml These values work with the default templates, however, you will likely wish to adjust these values especially if you have customised the layout or added extra attributes as facets.

The CSS added is easy to remove and replace with your own via layout XML.

Vendor/Module/view/frontend/layout/klevu_category_index.xml

Vendor/Module/view/frontend/layout/klevu_search_results.xml


Examples given of how to do this in a module. These changes could alternatively be made in your theme(s).

Recommendations Banners

We also set a minimum height for the recommendations banner widgets. This is not added inside the widget as this could lead to duplication of code if there are multiple widgets on the page. We add this to the Klevu_Frontend.before.body.end container.

The CSS added is easy to remove and replace with your own via layout XML.

Vendor/Module/view/frontend/layout/default.xml


Example given of how to do this in a module. This change could alternatively be made in your theme(s).