core javascript initiation file

nice code. any way to tidy it up more?