Optimized DOM handling by removing dozens of consecutive operations