Refactor send javascript.