Extract JavaScript to index.js