move js code out of view