Optimize init JS, less repetition
Merge pull request #976 from darkwing/init-optimization

Optimize init JS, less repetition