Optimize random BG image javascript