Update main.js

Move var and init forward, use defined function in music auto-load and make the auto-load block more sense