JS optimization + formatting