JavaScript clean up in index template