main.js optimization