Refactor Javascript, get rid of inline scripts