Reduce DOM insertions and queries