Because updating the text affects the width/height of the element and the flow of the page, the entire document usually has to be laid out again whenever the DOM changes. However, you can do stuff so only part of the document needs to be re-laid out.
From http://wilsonpage.co.uk/introducing-layout-boundaries/
To be a layout boundary, the element must:
- Be an SVG root (
<svg>
).
- Be a text or search
<input>
field.
or:
- Not be display inline or inline-block
- Not have a percentage height value.
- Not have an implicit or auto height value.
- Not have an implicit or auto width value.
- Have an explicit overflow value (scroll, auto or hidden).
- Not be a descendant of a table element.
If you make the element you're updating a layout boundry, only the part of the document inside your element needs to be updated. However, keep in mind were talking about optimizations of less than a millisecond, and pre-mature optimizations are generally considered bad practice.