Sunday 22 July 2018

Sitecore SXA : Disable Asset Optimizer

1 comment
Asset Optimizer is a good feature of Sitecore SXA as it improves the end user experience by minifying CSS styles and javascripts thus reducing the amount of data that needs to be transferred over HTTP request.  If Asset Optimizer is enabled, then Sitecore will automatically generate optimized.min.js and optimized.min.css. It is recommended to enable Asset Optimizer for production environment but sometimes you need to disable Asset Optimizer in non-prod environment (DEV, QA or STAGING) to troubleshoot or debug website scripts and css styles. In this blog post, I am doing to show few ways to disable Sitecore SXA Asset Optimizer:

Disable the Asset Optimizer globally

You can disable Asset Optimizer at global level for all SXA sites. In the Sitecore Content Editor, navigate to /sitecore/system/Settings/Foundation/Experience Accelerator/Theming/Optimiser and for both Scripts and Styles sitecore items select Mode as Disabled to disable Asset Optimizer. Save and publish your changes.

Disable asset optimizer for a specific SXA site

You can disable Asset Optimizer for a specific SXA site. In the Content Editor, navigate to /sitecore/content/…/SXA_SITE_NAME/Presentation/Page Designs. In the Asset Optimization section, in the Styles Optimizing Enabled and Scripts Optimizing Enabled fields set field value as NO to always disable optimization for SXA site.

Disable asset optimizer temporarily for a specific sitecore page

Even with the Asset Optimizer enabled, you can temporarily disable the assets optimisation on any Sitecore page. All you need to do is pass aodisabled=1 as query string parameter to your request url. For example: https://local.mysxaplayground.net/viewlocations?aodisabled=1
It is best practice to disable the Asset Optimizer in non-production environments and to enable it in production environments.
Comments and suggestions are most welcome. Happy coding!

1 comment :