Loops should be optimized because running complex operations or DOM manipulation inside loops might be expensive. Precomputation of values outside loops and efficient constructs like for will do a great job of improving performance.