When Salesforce Commerce Cloud generates web pages on the application server, it uses ISML Templates and scripts within the Controllers. B2C Commerce Script API in the Controllers access the database layer if necessary. We are going to describe the best practices for:
ISML Templates
Scripting in Templates
Local Includes
Remote Includes
Efficient Template Coding
Imagine what you’re missing in our other guides! Stay ahead of the competition, get exclusive pro tips, and master Salesforce Commerce Cloud like never before.
👉 Subscribe NOW and never struggle with SFCC again!
You should keep ISML as clean as possible. It’s always good for performance tuning and maintainability of your site.
You can write Salesforce Commerce Cloud scripts inside ISML templates using <isscript>
tag. In general though, you should use scripts in your controllers and pass the information via viewData rather than using <isscript>
blocks.
To ensure that you can diagnose performance issues, break large <isscript>
blocks into multiple pieces. Smaller scripts help with readability and pinpointing bottlenecks efficiently.
Local includes are useful when you want to reuse partial templates. They are merged with the including template as an ISML file before it is compiled.
Pipeline dictionary variables (pdict) can be used in the included templates as well, without needing to initialize and fetch data again if the variables are already available.
Example:<isinclude template="/components/your-template.isml" />
For each remote include in a page, a placeholder is inserted and a page is delivered from the application server to the web server. The web server parses the page and calls for every include placeholder, which can cause "Ping-Pong" between the two servers.
Best practices for remote includes:
Do not use more than 20 remote includes within a page.
Avoid exceeding three levels of remote includes.
Reuse pipeline dictionary variables instead of recalculating data in separate includes.
Example:<isinclude url="${URLUtils.https('Home-Show')}" />
Controllers should capture most of the business logic, while templates should only render the information aggregated in the controllers.
Use pagination to display large search result sets.
Remove unused SFRA/SiteGenesis ISML templates to avoid unnecessary resource consumption.
Use <isdecorate>
to apply a page layout wrapper around content blocks.
Use <ismodule>
when you have code snippets reused in multiple templates.