Couple of things from my side:- try to use the expressions first, rather than writing code- some logic can be written in just a couple of lines in JavaScript- if you need to write code use SlingModels, WCMUsePojo is harder to reuse/test- avoid <sly />, data-sly-unwrap and stick with the HTML output ...