Modularize profile javascript

@rlucioni @AlasdairSwan Please review.
Likewise here:

```
/** Retrieve a cookie value.
```