js function and template files