HiAs mentioned, the best practice is to modify anything at JCR level,
create a service/Component.The Sightly JavaScript Use-API enables a
Sightly file to access helper code written in JavaScript. This allows
all complex business logic to be encapsulated in the JavaScript code,
while the Sightly code deals only with direct markup
production.Reference good article to read is :-
http://blogs.adobe.com/experiencedelivers/experience-management/sightly-intro-part-4/I
hope this would be helpful to you....