The use of inner HTML in JavaScript has the following disadvantages −
There is no append support without reparsing the whole innerHTML. This makes changing innerHTML directly very slow.
For example, for appending to an HTML tag, you'll need to do the following −
let myDiv = document.querySelector('#myDiv')
// Reparses the whole myDiv tag.
myDiv.innerHTML += '<p>Added new tag</p>'innerHTML does not provide validation and therefore we can potentially insert valid and broken HTML in the document and break it.
The innerHTML property is extremely popular because it provides a simple way to completely replace the contents of an HTML element. Another way to do that is to use the DOM Level 2 API (removeChild, createElement, appendChild) but using innerHTML is by far the easiest and most efficient way to modify the DOM tree. However, innerHTML has few problems of its own that you need to be aware of: