implement caching of templates also on JS