performatic changes

I've made some changes in the main.js aiming for a better perfomance in the page load.