DOM insertion optimization