DEV Community

Discussion on: innerHTML Vs. textContent: The subtle difference.

Collapse
 
chayimfriedman2 profile image
Chayim Friedman • Edited

Project Trusted Types, for example, prevents (not completely though, allows custom sanitizers) the use of innerHTML.

The alternative is very simple (although somewhat more verbose): document.createElement() and appendChild() etc..

Even better and faster are document fragments.