JS cleanup in template