modify existing javascript to speed up page load