Extract javascript inside main.html to main.js