Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Is it good to use Sling Re-Writer concept

Avatar

Level 8

Hello All,

 

For my AEM application, need to iterate the page(during page load) to get the href link and based on some condition, append some values to those links.  Is it good to use Sling re writer concept?

Earlier, team has used javascript logic to iterate the page. get href link. modify the link based on condition. But this has severe impact on page performance. 

So, thought of using Sling rewriter concept. But we are worried about the page performance. Since, this logic executes for each and every page and needs to iterate all the href links.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @Mahesh_Gunaje ,

Compared with JS logic, Sling rewriters can offer better performance because the modifications are applied on the server side before the content is sent to the client. Considering good practice it's always better for future management. However, it's important to keep in mind that any server-side processing can introduce overhead, especially if the rewriting logic is complex or involves iterating over a large number of links.

 

If the rewriting logic doesn't depend on dynamic data or user-specific information, consider caching the rewritten content to improve performance further. Ensure your rewriting logic is efficient, optimized and avoid unnecessary iterations or computations.
If you still want to see the visual effect rather than the theoretical talk, you can perform a load test. One is without a transformer and another one is after adding the transformer code.

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi @Mahesh_Gunaje ,

Compared with JS logic, Sling rewriters can offer better performance because the modifications are applied on the server side before the content is sent to the client. Considering good practice it's always better for future management. However, it's important to keep in mind that any server-side processing can introduce overhead, especially if the rewriting logic is complex or involves iterating over a large number of links.

 

If the rewriting logic doesn't depend on dynamic data or user-specific information, consider caching the rewritten content to improve performance further. Ensure your rewriting logic is efficient, optimized and avoid unnecessary iterations or computations.
If you still want to see the visual effect rather than the theoretical talk, you can perform a load test. One is without a transformer and another one is after adding the transformer code.