Not all styles and scripts are loaded on SXA page


Description

Not all styles or scripts can be loaded on SXA page if their amount is more than 100. SXA uses Sitecore queries to get scripts and styles in the AssetLinksGenerator.GetScriptLinks and AssetLinksGenerator.GetStylesLinks methods, for example:

QueryAssets(theme, "./Scripts//*[@Extension='js']")
QueryAssets(theme, "./Styles//*[@Extension='css']")

By default, the maximum number of items in a query result set is 100. This means that only the top 100 scripts or styles can be rendered. It is controlled by the Query.MaxItems setting defined in the \App_Config\Sitecore.config file.

This issue affects SXA 1.0 - 1.8.1 versions.

Solution

Consider increasing the Query.MaxItems setting value to 300 or higher as follows:

<setting name="Query.MaxItems" value="300" />

Note: the default value of the setting can be overridden to 260 by Sitecore.ExperienceExplorer.config file for some Sitecore CMS/XP versions. Therefore, check the configuration settings to apply the changes to the proper config file.