Add some routines as modules.
Use local JS version for development.
Decouple modules.
Make realtime analytics a module and structure it in event-driven form.