fix javascript loading

- change order of javascript loading
- put javascript loading at the end of body