refactors javascript files

- allows hosting in a subfolder
- introduces async loading