Refactor local/remote js

Moves local server specific .js code to `local.js`.