Formatter functions wrapped into js initialiser

  This allows for private functions and variables

@maxfliri
Improve code readability

@maxfliri